Delfins Posted September 23, 2005 Report Posted September 23, 2005 (edited) Hi. tipa eventi nestrādā uz FF ? :o :unsure: onclick="doSomething();" function doSomething(e) { var isSet = ( typeof(e) != "undefined" ); alert(isSet); } Edited September 23, 2005 by Delfins
Delfins Posted September 23, 2005 Author Report Posted September 23, 2005 Solved: handlers tiek pieškirts caur JavaScriptu obj.ionclick = handler; nevis caur HTML-u onclick="handler();"
bubu Posted September 23, 2005 Report Posted September 23, 2005 A bet loģiski. Vajag taču šitā: onclick="doSomething(this);" function doSomething(e) { var isSet = ( typeof(e) != "undefined" ); alert(isSet); }
Delfins Posted September 23, 2005 Author Report Posted September 23, 2005 bubu, tavā variantā būs `e = Objekts` , a man vajag `e = Event` vot kā man dabūt tekošo pozīciju x/y peles kursoram?
bubu Posted September 23, 2005 Report Posted September 23, 2005 Ek eventu tev vajag. Nu jā, tad nelieto šo (html'isko) metodi. Man liekas tā nemaz ar nevarēs.
Delfins Posted September 23, 2005 Author Report Posted September 23, 2005 http://no.good.lv/testi/mapeditor/ vajag tekošo x/y attiecībā pret to objektu uz kura tika nospiests (pirmais objekts), parentos var skipot..
Delfins Posted September 23, 2005 Author Report Posted September 23, 2005 this.x this.y diemžēl šīs TOP/LEFT koordinātes strādā tikai iekš FF :((
Delfins Posted September 23, 2005 Author Report Posted September 23, 2005 (edited) Final result: IE_6 / FF_1.0.7 / Opera_8.5 function handleImageClick(e) { var posx = 0; var posy = 0; if ( typeof(e) == "undefined" ) var e = window.event; if ( typeof(opera) != "undefined" || typeof(document.all) != "undefined" ) { posx = e.offsetX; posy = e.offsetY; } else { posx = e.pageX - this.x; posy = e.pageY - this.y; } } Edited September 23, 2005 by Delfins
Recommended Posts