When the page load is done to do something: in general, the response load order of a page is: Domain name resolution-loading html-loading JS and css-loading pictures and other information.
1.window.onload Events
Effect: Triggers when all the resources on the page have been loaded. A slow response to a resource such as a large picture on the page can cause the Window.onload event to delay the triggering
Principle: One is ready, indicating that the document structure has been loaded (does not contain picture non-text media files).
The second is onload, which indicates that all elements, including pictures and other files, are loaded and completed.
Code:
1 function () {2 // Do something 3 4 }
2.Dom Ready
Effect: When the first step is complete, the DOM ready event is triggered.
Code:
1 The first type: the abbreviation for JQ ready ()2$(function(){3 //Do something4 })5 6 The second type:7$ (document). Ready (function(){8 //Do something9 })Ten One The third: The default parameter for jquery is: Document A$ (). Ready (function(){ - //Do something -})
Dom ready and DOM load usage:
Dom ready: After the DOM is loaded, you can directly manipulate the DOM, such as a picture as long as the tag is complete, do not wait for the picture to be loaded, you can set the image width of the properties and styles, etc., you can use the DOM ready.
Dom Load: It is possible to manipulate the DOM directly after loading the entire DOM document (including other information such as loading pictures), such as a picture to be loaded before the image can be set to the width of the property and style.
Reference Document: Http://www.cnblogs.com/zhangziqiu/archive/2011/06/27/DOMReady.html
Http://wenku.baidu.com/link?url= Extgn5g-s7nrxv5ugfy5qjyrwurjp48ysumpgv-hqlctzeudlmi3vdau6t4ux4ycdvtcranjzdsbpwvn4ka9a_8adavlvsagbyvkdre2ogo
DOM Ready Brief