Created
June 10, 2013 10:52
-
-
Save rainyjune/5747933 to your computer and use it in GitHub Desktop.
onload function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addOnload(newFunction) { | |
var oldOnload = window.onload; | |
if(typeof oldOnload === "function") { | |
alert("OldOnload is not null"); | |
window.onload = function() { | |
if (oldOnload) { | |
alert("OLD found, Let do OLD"); | |
oldOnload(); | |
} | |
alert("Do new function"); | |
newFunction(); | |
}; | |
} else { | |
alert("First run,set oldOnload"); | |
window.onload = newFunction; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment