Created
December 1, 2014 14:31
-
-
Save keenwon/cc3c1d821c0cab5ed604 to your computer and use it in GitHub Desktop.
原生的window.onload包装
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 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