Home > Web Front-end > JS Tutorial > Introduction to using n window onload loading examples at the same time_javascript skills

Introduction to using n window onload loading examples at the same time_javascript skills

WBOY
Release: 2016-05-16 17:35:24
Original
1198 people have browsed it
Copy code The code is as follows:

/*
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" );
});
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template