Created
September 21, 2011 19:44
-
-
Save llkats/1233086 to your computer and use it in GitHub Desktop.
add/attach event listeners for modern browsers and IE
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
addListener = (elt, type, fn) -> | |
if elt.addEventListener then elt.addEventListener(type, fn, false) | |
else if elt.attachEvent then elt.attachEvent('on' + type, fn) |
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
addListener = function(elt, type, fn) { | |
if (elt.addEventListener) { | |
elt.addEventListener(type, fn, false); | |
} else if (elt.attachEvent) { | |
elt.attachEvent('on' + type, fn); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment