Created
November 13, 2013 11:06
-
-
Save callblueday/7447302 to your computer and use it in GitHub Desktop.
Internet Explorer 从 5.0 开始提供了一个 attachEvent 方法,使用这个方法,就可以给一个事件指派多个处理过程了。attachEvent 对于目前的 Opera 也适用。但是问题是 Mozilla/Firefox 并不支持这个方法。但是它支持另一个 addEventListener 方法,这个方法跟 attachEvent 差不多,也是用来给一个事件指派多个处理过程的。但是它们指派的事件有些区别,在 attachEvent 方法中,事件是以 “on” 开头的,而在 addEventListener 中,事件没有开头的 “on”,另外 addEventListener 还有第三个参数,一般这个参数指定为 false 就可以了。
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
if (window.attachEvent) { | |
window.attachEvent("onload", remove); | |
} else if (window.addEventListener) { | |
window.addEventListener("load", remove, false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment