Created
April 19, 2012 16:27
-
-
Save gregdangelo/2422137 to your computer and use it in GitHub Desktop.
add event function
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 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