Generally speaking, we use the direct quantity of function in JS to name a simple function.
<script type="text/javascript">
var func=function(s){(s)};
func("never-online")
</script>
This is also legal in IE or Mozilla (there is a definition of direct function quantities in the ECMA standard).
But there is another simpler naming method in IE that can simplify our code:
<div ></div>
<script type="text/javascript">
var $=;
alert($("demo").innerHTML);
</script>
This does not report a syntax error in Mozilla, but throws an exception, and the operator is illegal:
The following code is to catch the exception thrown by Mozilla and print it out
<div ></div>
<script type="text/javascript">
var $=;
try {
alert($("demo").innerHTML);
} catch(ex) { (ex)}
</script>
The exception content is:
[Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: file:///C:/Documents%20and%20Settings/Administrator/Local%20Settings/Temp/ :: :: line 22" data: no]
It is not known whether it can be set in Mozilla's config. In short, you should pay attention when writing code.
I searched the keyword getElementById 0x8057000c on Google, and there are still many similar situations, such as
/group//browse_thread/thread/65a1a23f5dd7c9ad/d264d04d9d768b28?tvc=2#d264d04d9d768b28
There is no better solution, but it can be adapted, than writing this way
<div ></div>
<script>
document.$ = ;
alert(document.$("foo").innerHTML);
</script>
Because js can dynamically add properties and methods to objects, the above examples can be tested in ie and moz.
<script type="text/javascript">
var func=function(s){(s)};
func("never-online")
</script>
This is also legal in IE or Mozilla (there is a definition of direct function quantities in the ECMA standard).
But there is another simpler naming method in IE that can simplify our code:
<div ></div>
<script type="text/javascript">
var $=;
alert($("demo").innerHTML);
</script>
This does not report a syntax error in Mozilla, but throws an exception, and the operator is illegal:
The following code is to catch the exception thrown by Mozilla and print it out
<div ></div>
<script type="text/javascript">
var $=;
try {
alert($("demo").innerHTML);
} catch(ex) { (ex)}
</script>
The exception content is:
[Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: file:///C:/Documents%20and%20Settings/Administrator/Local%20Settings/Temp/ :: :: line 22" data: no]
It is not known whether it can be set in Mozilla's config. In short, you should pay attention when writing code.
I searched the keyword getElementById 0x8057000c on Google, and there are still many similar situations, such as
/group//browse_thread/thread/65a1a23f5dd7c9ad/d264d04d9d768b28?tvc=2#d264d04d9d768b28
There is no better solution, but it can be adapted, than writing this way
<div ></div>
<script>
document.$ = ;
alert(document.$("foo").innerHTML);
</script>
Because js can dynamically add properties and methods to objects, the above examples can be tested in ie and moz.