Skip to content

Instantly share code, notes, and snippets.

@elrrrrrrr
Created August 18, 2014 07:20
Show Gist options
  • Save elrrrrrrr/dacad7fb8a4ceec5e842 to your computer and use it in GitHub Desktop.
Save elrrrrrrr/dacad7fb8a4ceec5e842 to your computer and use it in GitHub Desktop.
添加事件监听
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