Windowonload is used to load multiple objects at the same time. If you want to load multiple objects at the same time, you will not be able to use them. Next, let's introduce the specific usage methods in detail. If you are interested, refer
The Code is as follows:
/*
1. obj is equivalent to window
2. type is equivalent to onload
3. fn is equivalent to an anonymous Function
*/
Function addEvent (obj, type, fn ){
Var saved = null; // The user saves the previous event
If (typeof obj ["on" + type] = "function "){
Saved = obj ["on" + type]; // The user saves the previous event.
};
// Execute the event
Obj ["on" + type] = function (){
If (saved ){
Saved ()
};
Fn ();
};
};
AddEvent (window, "load", function (){
Alert ("My name is Alibaba Cloud 1 ");
});
AddEvent (window, "load", function (){
Alert ("My name is Alibaba Cloud 2 ");
});
AddEvent (window, "load", function (){
Alert ("My name is Alibaba Cloud 3 ");
});