One, Window.onload () {}
Wait until all the elements in the page that contain the picture are loaded before they can be executed
Two, $ (function () {})
When the DOM structure is drawn, it does not have to wait until the load is complete.
Third, knowledge
Addloadeven: Triggers an event when the page is loaded for the first time
!!! -JavaScript
The first of these methods
Window.onload=function ()
{
FN1 ();
FN2 ();
}
function fn1 ()
{
Alert (' 1 '); Perform 1 first, top-down execution
}
function fn2 ()
{
Alert (' 2 '); Post-execution 2, top-down execution
}
The second method of
OnLoad Event Listener function
function Addloadevent (func)
{
var oldonload=window.onload;
if (typeof window.onload!= "function")
{
Window.onload=func;
}
Else
{
Window.onload=function ()
{
Oldonload ();
Func ();
}
};
}
Function F1 () {alert (' 1 ');}
function F2 () {alert (' 2 ');}
Function F3 () {alert (' 3 ');}
function F4 () {alert (' 4 ');}
Call
Addloadevent (F1);
Addloadevent (F2);
Addloadevent (F3);
Addloadevent (F4);
shui-performing multiple Window.onload