Skip to content

Instantly share code, notes, and snippets.

@gregdangelo
Created April 19, 2012 16:27
Show Gist options
  • Save gregdangelo/2422137 to your computer and use it in GitHub Desktop.
Save gregdangelo/2422137 to your computer and use it in GitHub Desktop.
add event function
function addEvent(target, type, handler) {
if (target.addEventListener){
target.addEventListener(type, handler, false);
}else{
target.attachEvent("on" + type,
function(event) {
// Invoke the handler as a method of target,
// passing on the event object
return handler.call(target, event);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment