Recently, when I changed a page embedded in the frame, jquery was used for the effect, and the page itself was bound with the onload event. After the change, the test in Firefox is normal and smooth. in IE, it takes more than a dozen seconds for jquery to show up, and daylily is getting cooler. Recently, when I changed a page embedded in the frame, jquery was used for the effect, and the page itself was bound with the onload event. After the change, the test in Firefox is normal and smooth. in IE, it takes more than a dozen seconds for jquery to show up, and daylily is getting cooler.
At first, we thought it was a conflict with the onload loading method. $ (Document) is widely used on the Internet ). ready () is executed after the DOM parsing of the page is complete, while the onload event is executed after all resources are ready, that is, $ (document ). ready () is executed before onload, especially when the page image is large, the time difference may be greater. However, this page clearly shows that the images have been displayed for more than a dozen seconds, and jquery's effect is not displayed yet.
Try to delete the onload loading method. The result is the same. It seems that there is no need to bind the original onload event to $ (document). ready () for writing. What makes Firefox normal and IE can do that? After debugging, we found that the original onload method bound to IE exceeded $ (document ). ready (), while Firefox executes $ (document) first ). ready (), and then execute the original onload method. This is not exactly the same as the online statement.
Go through the jquery source code and see how $ (document). ready () is implemented:
The Code is as follows:
If (jQuery. browser. msie & window = top) (function (){
If (jQuery. isReady) return;
Try {
Document.doc umentElement. doScroll ("left ");
} Catch (error ){
SetTimeout (arguments. callee, 0 );
Return;
}
// And execute any waiting functions
JQuery. ready ();
})();
JQuery. event. add (window, "load", jQuery. ready );
The result is clear. IE runs $ (document) first only when the page is not embedded with frame, like Firefox ). ready (), and then execute the original onload method. For pages embedded in the frame, it is only bound to the load event for execution. Therefore, it is only after the execution of the original onload binding method. The page shows that there is an inaccessible resource in the test environment, and the latency of over 10 seconds is the time difference it zoomed in.
Author: Joyce Liu