Skip to content

Instantly share code, notes, and snippets.

@terkel
Created October 8, 2011 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terkel/1271790 to your computer and use it in GitHub Desktop.
Save terkel/1271790 to your computer and use it in GitHub Desktop.
addEvent
// 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