<textarea id="runcode91822"><! 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 </l i> <li> Open </li> <li> open </li> </body> </ptml> <script language= "ja Vascript "type=" Text/javascript "> Document.body.onclick = function (evt) {evt = evt | | window.event; var o = Evt.target | | Evt.srcelement; window.open (O.previoussibling.href | | o.previoussibling.previoussibling.href); return false; } </script></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Find Document.body.onclick = function (evt),
In IE, this evt is not, but under the Firefox (opera seems to be) will pass this parameter by default. In IE, this parameter is null, want to be compatible, just write.
Continue downward,
EVT = EVT | | window.event;
In IE, EVT will point to: Window.event, under Firefox, will point to that default parameter.
Because under IE evt | | Window.event equivalent to: null | | Window.event, the result is still window.event.
And in Firefox, it's the equivalent of EVT | | NULL, the result is evt
Next look:
O.previoussibling.href | | O.previoussibling.previoussibling.href
The previous expression is used under IE, and the latter one is used under Firefox.
Because in IE, XMLDOM did not preservewhitespace this attribute, namely: The blank also as a node, and IE defaults to false, that is, the white space is not regarded as a node.
Speaking of XMLDOM, it seems to be irrelevant, but under Firefox previoussibling is blank, unless there are no spaces between the two HTML tags.
<a href= "Http://www.blueidea.com/articleimg/bbsimg/smile.gif"/></a>
<a href= "http://www.jb51.net/article/picture Address" > Open </a>
Two <a> there is a newline (one of the spaces), so under Firefox, take the following one <a> the previous node, you must use:
O.previoussibling.previoussibling.href
Maybe you still don't understand, it doesn't matter, in a simple:
<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 All SELECT Note: If the need to introduce external JS need to refresh to perform]