Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 新的DOM2 用法可以addEventListener()這個函數來觀察到:
- addEventListener(event,function,capture/bubble);
- 參數event如上表所示, function是要執行的函數, capture與bubble分別是W3C制定得兩種時間模式,簡單來說capture就是從document的開始讀到最後一行,
- 再執行事件, 而bubble則是先尋找指定的位置再執行事件.capture/bubble的參數是布林值, True表示用capture, False則是bubble.Windows Internet Explorer
- 也有制定一種EventHandler, 是 attachEvent(), 格式如下:
- window.attachEvent("submit",myFunction());
- 比較特別的是attachEvent不需要指定capture/bubble的參數, 因為在windows IE環境下都是使用Bubble的模式.
- W3C 及 IE 同時支援移除指定的事件, 用途是移除設定的事件, 格式分別如下:
- W3C格式:
- removeEventListener(event,function,capture/bubble);
- Windows IE的格式如下:
- detachEvent(event,function);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement