Created
August 18, 2014 07:20
-
-
Save elrrrrrrr/dacad7fb8a4ceec5e842 to your computer and use it in GitHub Desktop.
添加事件监听
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
function addListener(target, type, handler) { | |
if (target.addEventListener) { | |
target.addEventListener(type, handler, false) | |
} else if (target.attachEvent) { | |
target.attachEvent("on" + type , handler); | |
} else { | |
target["on" + type] = handler; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment