Code seen from Cnblogs, the author's code is not compatible with Firefox but, to help you learn why the following code is compatible with Firefox, we can compare, to help learn, for more articles can refer to the cloud-Habitat community previously published articles.
<textarea id="runcode33317"><ptml> <pead> <script language= "JavaScript" > Function mouseover () {var objtd=window.event.srcel ement; var objtr=objtd.parentelement; var Y=objtr.rowindex; var X=objtd.cellindex; Alert (x+ "" +y); </script> </pead> <body> <table width= "$" border= "1" > <tr> <td onclick= "Mouseov ER () "> </td> <td onclick=" mouseover () "> </td> <td onclick=" mouseover () " > </td> </tr> <tr> <td onclick= "mouseover ()" > </td> <TD Onclick= "MouseOver ()" > </td> <td onclick= "mouseover ()" > </td> </tr> <tr> <td onclick= "mouseover ()" > </td> <td onclick= "mouseover ()" > </td > <td onclick= "mouseover ()" > </td> </tr> </table> </body> </ptml> </c 0></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
The following code is a modified Firefox-compatible code for the cloud-dwelling community
<ptml> <pead> <script language= "JavaScript" > function mouseover (e) {e=window.event?window.event:e; var objtd=e.srcelement?e.srcelement:e.target; var Objtr=objtd.parentnode; var Y=objtr.rowindex; var X=objtd.cellindex; Alert (x+ "" +y); </script> </pead> <body> <table width= "$" border= "1" > <tr> <td onclick= "Mouseov ER (arguments[0]) "> </td> <td onclick=" mouseover (arguments[0)) "> </td> < TD onclick= "MouseOver (Arguments[0])" > </td> </tr> <tr> <td onclick= "MouseOver" ( Arguments[0] "> </td> <td onclick=" mouseover (arguments[0)) "> </td> <TD onclick= "MouseOver (Arguments[0])" > </td> </tr> <tr> <td onclick= "MouseOver" ( Arguments[0] "> </td> <td onclick=" mouseover (arguments[0)) "> </td> <TD onclick= "MouseOver (Arguments[0])" > </td> </tr> </table> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
The main differences are as follows:
1. Event e.srcelement and E.target
It is often asked how to use the Event.srcelement under Firefox, in this detailed description:
Under IE, the event object has a srcelement attribute, but no target attribute; Firefox, the event object has the target attribute, but there is no srcelement attribute. But their role is quite, namely:
Firefox under the Event.target = IE under the Event.srcelement
Workaround: Use obj (obj = event.srcelement event.srcElement:event.target) to replace the event.srcelement under IE or the Event.target under Firefox.
the difference between 2.parentNode and parentelement
Use parentelement in FF invalid, search just know parentelement it is ie dedicated, ie years of hegemony caused many applications can not be compatible with other browsers, standardization is really important, hehe, must be to the standards of the Web OH