Window. onload = function () {alert ("welcome ");}
In this way, you want to automatically execute the defined JavaScript code after loading the page.Code(Function ).
Most of these requirementsProgramMembers will do this.
When learning jquery core functions, the $ (document). Ready (function () {...}) function is used to replace window. onload on the page;
However, $ (document) is used at startup today ). when the ready (function () {}) page (A 3 m image is used on the page), it is found that the image has not been fully loaded,
The code in function () has been executed.
The difference between shrinking the two on the Internet has found that some people have had similar experiences and have doubts (replacing window. onload means equivalent ?).
This reminds me of a sentence in jquery API.
"Allows you to bind a function to be executed when the DOM document has finished loading. "
The Chinese meaning is:
"Allows you to bind a function that is executed after the DOM document is loaded ."
Dom document loading and page loading are different, which directly shows that there is a big difference between the two.
Page loading includes at least Dom document loading (that is, the Code organization you write) and page content loading.
In this way, the difference and essence between the two are obvious.