Yesterday, zchiy2k asked me how jquery handled Dom loading and document loading. I didn't answer the question at the moment, in development, I have never handled the issue of waiting for all the page content to be loaded. In fact, in jquery, processing the loading of documents is usually a very common load event, but listening to Windows. I sorted it out today. By the way, I despise myself for front-end development so long that I don't even know this.
Full page loading means that all content on the page is fully loaded, including windows, frames, objects, and images. In jquery, this goal is achieved by listening to the load events of windows. This event will delay the execution of JavaScript code because the page may contain a large number of images or even flash.
$ (Window). Load (function () {alert ('page Load completed ');});
If the library is not used for development, listening to this event with native Javascript is also very simple:
Window. onload = function () {alert ('page Load completed ');}
The most common practice is to execute JavaScript code when Dom construction is complete, so that the code can be executed as soon as possible on the premise that the page elements are complete, the ready function may be the first class for most people who have studied jquery.
$ (Document ). ready (function () {alert ('dom loaded completion ') ;}); // normally we are lazy: $ (function () {alert ('dom loaded completion ');});
For those who intend to use native JavaScript for development, domready is a very rigorous and reliable microlibrary that checks whether the Dom is ready.
From: http://www.jsmix.com/javascript/document-ready-window-load.html