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 '); " The value of ></script>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 judgment statement of FF, because there is no readyState this person value under FF, IE's readyState must have value | | this.readystate== ' loaded ' | | this.readystate== ' complete ' //This is IE's judgment statement ) { Alert (' Loaded ');} };
document
returns "Loading" when the document is loading. Returns "Interactive" and raises an event when the document finishes rendering but when an inline resource is loaded DOMContentLoaded
. When the document is loaded, return "complete" and raise the load
event.
readystatechange事件
Will be in
document
Occurs when the property value of the ReadyState property on an object changes. Syntax
var string = document.readyState;
Example
//analog domcontentloadeddocume Nt.onreadystatechange = function ({if (Document.readystate == " interactive "{initapplication (}} /span>
//simulation Load event Document.onreadystatechange = function {if .readystate == "complete ") {initapplication }
<iframe src="../../planmanage/planmanage/planBaseInfoAction.do?doType=212" width="98%" height="330" scrolling="no" frameborder="0" id="content51" name="content50" style="visibility: hidden;" onreadystatechange="stateChangeIE(this,‘loading50‘)" onload="stateChangeFirefox(this,‘loading50‘)"></iframe>
The difference between onreadystatechange and onload in JS