EventTarget
Resumo
EventTarget
é uma interface DOM implementada por objetos que podem receber eventos DOM e tem que ouvir estes.
Element
, document
, e window
são os mais comuns disparadores de eventos, mas outros objetos podem disparar eventos também, por exemplo XMLHttpRequest
, AudioNode
, AudioContext
e outros.
Muitos disparadores de eventos (incluindo elements, documents, e windows) também suportam definir event handlers (en-US) através on...
propriedades e atributos.
Métodos
EventTarget.addEventListener()
-
Registra um tratamento para um tipo específico de evento sobre o
EventTarget
. EventTarget.removeEventListener()
-
Remove um event listener do
EventTarget
. EventTarget.dispatchEvent()
-
Dispatch an event to this
EventTarget
.
Especificações
Especificação | Status | Comentário |
---|---|---|
DOM The definition of 'EventTarget' in that specification. |
Padrão em tempo real | Sem mundanças. |
Document Object Model (DOM) Level 3 Events Specification The definition of 'EventTarget' in that specification. |
Obsoleto | Alguns parâmetros agora são opcionais (listener ), ou aceitam o valor null (useCapture ). |
Document Object Model (DOM) Level 2 Events Specification The definition of 'EventTarget' in that specification. |
Obsoleto | Definição inicial. |
Compatibilidade com navegadores
BCD tables only load in the browser
Veja também
- Referência de eventos (en-US) - os eventos disponíveis na plataforma.
- Guia do desenvolvedor sobre Eventos
- Interface
Event