Skip to content

Instantly share code, notes, and snippets.

@rainyjune
Created June 10, 2013 10:52
Show Gist options
  • Save rainyjune/5747933 to your computer and use it in GitHub Desktop.
Save rainyjune/5747933 to your computer and use it in GitHub Desktop.
onload function
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