Skip to content

Instantly share code, notes, and snippets.

@think49
Created December 29, 2010 19:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save think49/758906 to your computer and use it in GitHub Desktop.
Save think49/758906 to your computer and use it in GitHub Desktop.
addEvent.js: Node#addEventListener, attachEvent のラッパー関数。
/**
* addEvent.js
*
* @version 1.0
* @author think49
*/
/**
* addEventListener wrapper.
* @function
* @param {Object} node DOM Node.
* @param {String} type event type.
* @param {Object} listener EventListener.
* @param {Boolean} useCapture useCapture.
* @returns undefined
* @type Undefined
*/
var addEvent = (function () {
if (typeof addEventListener === 'function') {
return function (node, type, listener, useCapture) {
return node.addEventListener(type, listener, useCapture);
};
} else if (typeof attachEvent === 'function' || typeof attachEvent === 'object') {
return function (node, type, handler) {
return node.attachEvent('on' + type, handler);
};
}
})();
@think49
Copy link
Author

think49 commented Jan 12, 2011

参考URL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment