Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oreales/8966428 to your computer and use it in GitHub Desktop.
Save oreales/8966428 to your computer and use it in GitHub Desktop.
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