EventTarget
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
EventTarget
인터페이스는 이벤트를 수신할 수 있고, 수신한 이벤트에 대한 수신기(listener)를 가질 수 있는 객체가 구현하는 인터페이스입니다. 즉, 이벤트의 대상이 될 수 있는 객체는 EventTarget
의 세 메서드를 구현합니다.
Element
, Document
, Window
가 가장 흔한 이벤트 대상이며, 이외에도 XMLHttpRequest
, AudioNode
, AudioContext
등의 객체도 이벤트 대상입니다.
많은 이벤트 대상(요소, 문서, 창, ...)은 onevent
속성과 특성을 사용한 이벤트 처리기 등록도 지원합니다.
생성자
EventTarget()
-
새로운
EventTarget
객체 인스턴스를 생성합니다.
메서드
EventTarget.addEventListener()
-
EventTarget
에 특정 이벤트 유형의 처리기를 등록합니다. EventTarget.removeEventListener()
-
EventTarget
에서 이벤트 수신기를 하나 제거합니다. EventTarget.dispatchEvent()
-
EventTarget
으로 이벤트를 발송합니다.
명세
Specification |
---|
DOM # interface-eventtarget |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
EventTarget | ||||||||||||||
EventTarget() constructor | ||||||||||||||
addEventListener | ||||||||||||||
Form with options object supported (third parameter can be either options or a Boolean , for backwards compatibility) | ||||||||||||||
options.capture parameter | ||||||||||||||
options.once parameter | ||||||||||||||
options.passive parameter | ||||||||||||||
options.passive parameter defaults to true for touchstart and touchmove events | ||||||||||||||
options.passive parameter defaults to true for wheel and mousewheel events | ||||||||||||||
options.signal parameter | ||||||||||||||
useCapture parameter is optional | ||||||||||||||
dispatchEvent | ||||||||||||||
removeEventListener | ||||||||||||||
Form with options object supported (third parameter can be either options or a Boolean , for backwards compatibility) | ||||||||||||||
useCapture parameter is optional |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- No support
- No support
- See implementation notes.
- Has more compatibility info.