Recently, when I changed a page embedded in a frame, I used jquery to do the effect, and the page itself was bound to the OnLoad event. After the change, Firefox test under normal fluency, IE will wait for a few seconds of jquery effect only appear, Day Lily is cold.
At first thought it was conflicting with the method that was loaded by itself onload. The common saying on the Internet is $ (document). Ready () is executed after page Dom parsing completes, and the OnLoad event is executed after all resources are ready to be completed, that is, $ (document). Ready () is to be executed before the onload, Especially when the page picture is larger, this time difference may be greater. But I this page is clearly the picture is displayed for more than 10 seconds, still do not see the effect of jquery out.
Delete the OnLoad loading method try, the result is the same, it seems not necessary to the original OnLoad event binding also use $ (document). Ready () to write. What is the reason that makes Firefox normal and IE can? Then debugging, found that the original binding of IE under the OnLoad method before the $ (document). Ready (), while Firefox executes the contents of $ (document). Ready (), then executes the original OnLoad method. This and the online statement does not seem to be exactly the same ah, oh, a little meaning, as if more and more close to the truth.
Flip the source of jquery to see $ (document). Ready () How to achieve it:
Copy Code code as follows:
if (jQuery.browser.msie && window = top) (function () {
if (Jquery.isready) return;
try {
Document.documentElement.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 only if the page is not embedded in the frame in the case of Firefox and so on, the first execution of $ (document). Ready (), and then execute the original onload method. For a page embedded in a frame, it is only bound to execute on the Load event, so it is naturally only after the original onload-bound method is executed. And this page just in the test environment there is no access to the resources, the more than 10-second delay is that it magnified the time lag.
Author: Joyce Liu