The Wayback Machine - https://web.archive.org/web/20160207191249/https://developer.mozilla.org/zh-TW/docs/Web/API/EventTarget

We want to help developers like you. Tell us about how you work: http://qsurvey.mozilla.com/s3/Developer-Audience-Survey-V2/?s=mdn

EventTarget

翻譯不完整。請協助 翻譯此英文文件

EventTarget 是可以接收事件和監聽的物件實現的接口。

Elementdocument 和 window 為最常見的EventTarget ,但是也有其他的 Object 同樣也是 EventTarget ,例如 XMLHttpRequestAudioNodeAudioContext……等等。

許多事件的目標,例如 elements、documents、windows,可以藉由 properties 和attributes 設置 event handlers 。

方法

EventTarget.addEventListener()
註冊對EventTarget的事件監聽
EventTarget.removeEventListener()
移除對EventTarget的事件監聽
EventTarget.dispatchEvent()
EventTarget調度事件

Mozilla chrome code 的額外 Methods

Mozilla extensions for use by JS-implemented event targets to implement on* properties. See alsoWebIDL bindings.

  • void setEventHandler(DOMString type, EventHandler handler)
  • EventHandler getEventHandler(DOMString type)

 

技術文件

Specification Status Comment
DOM
The definition of 'EventTarget' in that specification.
Living Standard No change.
Document Object Model (DOM) Level 3 Events Specification
The definition of 'EventTarget' in that specification.
Working Draft A few parameters are now optional (listener), or accepts the null value (useCapture).
Document Object Model (DOM) Level 2 Events Specification
The definition of 'EventTarget' in that specification.
Recommendation Initial definition.

瀏覽器相容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 1.0 (1.7 or earlier) 9.0 7 1.0
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 1.0 1.0 (1) 9.0 6.0 1.0

 

參見

文件標籤與貢獻者

 此頁面的貢獻者: Shiyou, alk03073135, teoli
 最近更新: Shiyou,