The script element of IE only supports the onreadystatechange event, and the OnLoad event is not supported. The script element of FF does not support the onReadyStateChange event, only the OnLoad event is supported. If you want to perform an operation on a <script src= "xx.js" > Load, FF uses the OnLoad event, and IE combines onreadystatechange events and this.readystate,
Here is an example of IE:
<script type= "Text/javascript" src= "xx.xx" onreadstatechange= "if (this.readystate== ' Load ') alert (' Loaded ');" ></script>
The value of this.readystate ' loaded ' or ' complete ' can indicate that the script has been loaded. How to combine the differences between IE and FF? Refer to the source code for jquery:
var script = document.createelement (' script '); script.src= "Xx.js"; script.onload = Script.onreadystatechange = function () { if ( ! this.readystate //This is the FF's judgment statement, since FF does not have readyState this person value, IE's readyState must have value | | this.readystate= = ' Loaded ' | | this.readystate== ' complete ' //This is IE's judgment statement ) { alert (' Loaded ');} };
The difference between onreadystatechange and onload in JS