Skip to content

Instantly share code, notes, and snippets.

@keenwon
Created December 1, 2014 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keenwon/cc3c1d821c0cab5ed604 to your computer and use it in GitHub Desktop.
Save keenwon/cc3c1d821c0cab5ed604 to your computer and use it in GitHub Desktop.
原生的window.onload包装
/**
* 调用方法:
* function run(){
* //run.
* }
*
* windowOnload(run);
*/
function windowOnload(fun) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = fun;
} else {
window.onload = function () {
oldonload();
fun();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment