Use or | to be compatible with FireFox
Example:
Run code box
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ptml xmlns = "http://www.w3.org/1999/xhtml"> <pead> <meta http-equiv =" content-Type "content =" text/html; charset = UTF-8 "/> <title> Untitled Document </title> </pead> <body> <li> open </li> <li> open </li> </body> </ptml> <script language = "javascript" type = "text/javascript"> document. body. onclick = function (evt) {evt = evt | window. event; var o = evt.tar get | evt. srcElement; window. open (o. previussibling. href | o. previussibling. previussibling. href); return false;} script
[Ctrl + A select all tips: you can modify some code and then press run]
Find document. body. onclick = function (evt ),
In IE, this evt does not exist, but in fireFox (it seems like it is also in opera), this parameter is passed by default. in IE, this parameter is null. To be compatible, write it like this.
Continue down:
Evt = evt | window. event;
In IE, evt points to window. event. In fireFox, it points to the default parameter.
In IE, evt | window. event is equivalent to: null | window. event. The result is still window. event.
In fireFox, the result is evt | null.
Look down:
O. previussibling. href | o. previousSibling. previousSibling. href
The first expression is used for IE, and the other one is used for FireFox.
In FireFox, there is no preserveWhiteSpace attribute, that is, blank space is treated as a node, while in IE, the default value is false, that is, blank space is not considered as a node.
XMLDom seems unrelated to the above mentioned, but in FireFox, previussibling is blank unless there is no space between two HTML tags.
Open
There is a line break between the two (a space), so in FireFox, take the previous node of the following, you must use:
O. previussibling. previussibling. href
Maybe you still don't understand, it doesn't matter,Another simple example:
Run code box
Script function test (p1, p2, p3) {p1 = p1 | 100; p2 = p2 | "xlingFairy "; return "p1 =" + p1 + "p2 =" + p2 + "p3 =" + p3;} alert (test (); alert (test (null, null, "blueidea.com") script
[Ctrl + A select all tips: you can modify some code and then press run]