the role of Script.onload=script.onreadystatechange=function ():
in the code to determine whether the introduction of JS file is loaded, there is the existence of this statement, the following describes what its role.
for information on how to determine if the introduction of JS file is loaded, refer toJS How to determine whether the introduction of JS file loading is completea chapter.
The complete code is as follows:
Script.onload=script.onreadystatechange=function () {if (!this.readystate| | this.readystate== ' Loaded ' | | this.readystate== ' complete ') {//code} script.onload=script.onreadystatechange=null;}
Here's how this code works:
1.IE8 and IE8 The following browsers, the script tag does not support the OnLoad event, but supports the onreadystatechange event.
2.ie8 above browsers, Google Chrome and Mozilla Firefox support the OnLoad event.
3.readyState is a state of the onReadyStateChange event, when the value is loaded or complete, indicating that it has been loaded.
4.if (!this.readystate| | this.readystate== ' Loaded ' | | this.readystate== ' complete '),!this.readystate indicates that the following browsers are not IE11 (IE11 the following browsers also support onReadyStateChange events)
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=14776
Script.onload=script.onreadystatechange=function ()