Some code I did today had bits like this:
(function (){
var oldOnLoad = window.onload;
window.onload = function(e){
//DO SOME COOL STUFF
if(typeof oldOnLoad == "function"){
oldOnLoad(e);
}
}
})();
That was a decent way to not overwrite any existing window.onload code, but oldOnLoad isn't in the global space, because of the use of the closure.
No comments:
Post a Comment