Skip to content

Instantly share code, notes, and snippets.

@llkats
Created September 21, 2011 19:44
Show Gist options
  • Save llkats/1233086 to your computer and use it in GitHub Desktop.
Save llkats/1233086 to your computer and use it in GitHub Desktop.
add/attach event listeners for modern browsers and IE
addListener = (elt, type, fn) ->
if elt.addEventListener then elt.addEventListener(type, fn, false)
else if elt.attachEvent then elt.attachEvent('on' + type, fn)
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