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 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 entre navegadores
Estamos convertendo nossos dados de compatibilidade para o formato JSON.
Esta tabela de compatibilidade ainda usa o formato antigo,
pois ainda não convertemos os dados que ela contém.
Descubra como você pode ajudar!
Funcionalidade | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Suporte Básico | 1.0 | 1.0 (1.7 or earlier) | 9.0 | 7 | 1.0 |
Funcionalidade | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Suporte Básico | 1.0 | 1.0 (1) | 9.0 | 6.0 | 1.0 |
Additional methods for Mozilla chrome code
Mozilla extensions for use by JS-implemented event targets to implement on* properties. See also WebIDL bindings.
- void setEventHandler(DOMString type, EventHandler handler)
- EventHandler getEventHandler(DOMString type)
Veja também
- Referência de eventos - os eventos disponíveis na plataforma.
- Guia do desenvolvedor sobre Eventos
- Interface
Event