A message reminder function has been created in the recent project. After a user logs on to the project, a message module slides out from the lower right corner. Similar to the advertisement popped up by qq, it is only larger in the browser. The first practice is at $ (document ). in ready (), jQuery's slideDown is used to display the message div. Because there are six or seven iframe blocks in the page, each iframe has a long loading time and a large amount of content, as a result, if the iframe is not loaded, the message div is displayed, and the effect of the animation is unbearable. Later on the jQuery official site an article (http://learn.jquery.com/about-jquery/how-jquery-works/) found jQuery $ (document ). ready () is not executed after the page is fully loaded, but after the dom of the current page is loaded, it is very efficient and fast. However, if you want to wait until all pages are loaded, including the internal iframe, and then execute it, you need to use window. onload event. The following describes window. onload and $ (document ). the difference between ready () and ready. The execution time is different. The window is also mentioned above. onload can be executed only after all elements including images and iframe are loaded on the page, while $ (document ). ready () is executed after the DOM structure is drawn. You do not have to wait until the loading is complete. That is to say, the image may not be downloaded yet, and the iframe content has not been loaded yet. The execution time and function of the two are different. In most cases, $ (document ). ready () is better, but it is because $ (document ). when ready () is executed, the image and other content may not be fully loaded. To obtain the image size, this attribute is not necessarily valid. However, it is a waste of time to get the size of an image after loading all the pages. What should I do? Fortunately, jQuery provides us with a better way to use the load method to bind the events when the specified element is loaded, such as $ ("img "). load (function (){......}); The load method also has the advantage of simply writing windows. onload registers only the last event. If you want to register multiple events, you need additional code to determine the event. You can use jQuery's load method to register multiple events, $ (window ). load () and window. onload is equivalent, but the load method can register multiple events.