Skip to content

Instantly share code, notes, and snippets.

@oscar-reales-interactiv4
Created November 24, 2011 02:20
Show Gist options
  • Select an option

  • Save oscar-reales-interactiv4/1390489 to your computer and use it in GitHub Desktop.

Select an option

Save oscar-reales-interactiv4/1390489 to your computer and use it in GitHub Desktop.
js: unobstrusive onLoad script
function addEvent(obj, evType, fn){
if (obj.addEventListener){
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}
addEvent(window, 'load', foo);
addEvent(window, 'load', bar);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment