Created
December 29, 2010 19:05
-
-
Save think49/758906 to your computer and use it in GitHub Desktop.
addEvent.js: Node#addEventListener, attachEvent のラッパー関数。
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
/** | |
* 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); | |
}; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考URL