/*
1. obj is equivalent to window
2 , type is equivalent to onload
3, fn is equivalent to 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 event
obj[ "on" type ] = function(){
if( saved ){
saved()
};
fn();
};
} ;
addEvent( window,"load",function(){
alert( "I am 尜尜1" );
});
addEvent( window,"load",function() {
alert( "I am 尜尜2" );
});
addEvent( window,"load",function(){
alert( "I am 尜尜3" );
});
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn