Created
October 8, 2011 03:01
-
-
Save terkel/1271790 to your computer and use it in GitHub Desktop.
addEvent
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
// http://gihyo.jp/dev/serial/01/crossbrowser-javascript/0007 | |
var addEvent = (function () { | |
if (document.addEventListener) { | |
return function(node, type, handler) { | |
node.addEventListener(type, handler, false); | |
}; | |
} else if (document.attachEvent) { | |
return function(node, type, handler) { | |
node.attachEvent('on' + type, function (event) { | |
handler.call(node, event); | |
}); | |
}; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment