2.1.4 [DOM Level 2 - Events] Section 1.3.1, Event registration interfaces
V0009:
-
The EventTarget interface is implemented by all Nodes in an implementation which supports the DOM Event Model.
Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)
The EventTarget interface is not supported. Similar functionality is provided by the attachEvent, detachEvent, and fireEvent scripting methods.
V0010:
-
addEventListener This method allows the registration of event listeners on the event target. If an EventListener is added to an EventTarget while it is processing an event, it will not be triggered by the current actions but may be triggered during a later stage of event flow, such as the bubbling phase. If multiple identical EventListeners are registered on the same EventTarget with the same parameters the duplicate instances are discarded. They do not cause the EventListener to be called twice and since they are discarded they do not need to be removed with the removeEventListener method. Parameters type of type DOMString The event type for which the user is registering listener of type EventListener The listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs.useCapture of type boolean If true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered EventListener before being dispatched to any EventTargets beneath them in the tree. Events which are bubbling upward through the tree will not trigger an EventListener designated to use capture. No Return Value No Exceptions
Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)
The addEventListener method is not supported. Similar functionality is provided by the attachEvent(sEvent, fpNotify) scripting method.
Parameter:
sEvent Required. A string that specifies any of the standard DHTML events.
fpNotify Required. A pointer that specifies the function to call when sEvent fires.
Return Value:
Boolean.
true
= The function is bound successfully to the event.
false
= The function is not bound to the event.
IE9 Mode, IE10 Mode, IE11 Mode, and EdgeHTML Mode (All Versions)
Duplicate EventListener objects are discarded only if they are identical instances, without regard to the parameter signatures.
V0011:
-
dispatchEvent This method allows the dispatch of events into the implementations event model. Events dispatched in this manner will have the same capturing and bubbling behavior as events dispatched directly by the implementation. The target of the event is the EventTarget on which dispatchEvent is called. Parameters evt of type EventSpecifies the event type, behavior, and contextual information to be used in processing the event.
-
Return Value boolean The return value of dispatchEvent indicates whether any of the listeners which handled the event called preventDefault. If preventDefault was called the value is false, else the value is true.
-
Exceptions EventExceptionUNSPECIFIED_EVENT_TYPE_ERR: Raised if the Event's type was not specified by initializing the event before dispatchEvent was called. Specification of the Event's type as null or an empty string will also trigger this exception.
Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)
The dispatchEvent method is not supported. Similar functionality is provided by the fireEvent(sEvent [, oEventObject]) scripting method.
Parameter:
sEvent
Required. A string that specifies the name of the event to fire.
oEventObject
Optional. An object that specifies the event object from which to obtain event object properties.
Return Value:
true
= The event fired successfully.
false
= The event was canceled.
V0012:
-
removeEventListener This method allows the removal of event listeners from the event target. If an EventListener is removed from an EventTarget while it is processing an event, it will not be triggered by the current actions. EventListeners can never be invoked after being removed. Calling removeEventListener with arguments which do not identify any currently registered EventListener on the EventTarget has no effect. Parameters type of type DOMString Specifies the event type of the EventListener being removed. listener of type EventListener The EventListener parameter indicates the EventListener to be removed. useCapture of type boolean Specifies whether the EventListener being removed was registered as a capturing listener or not. If a listener was registered twice, one with capture and one without, each must be removed separately. Removal of a capturing listener does not affect a non-capturing version of the same listener, and vice versa. No Return Value No Exceptions
Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)
The removeEventListener method is not supported. Similar functionality is provided by the detachEvent(sEvent, fpNotify) scripting method.
Parameter:
sEvent
Required. A string that specifies the name of the event to raise.
fpNotify
Required. Pointer that specifies the function previously set using the attachEvent method.
Return Value:
No return value.
V0013:
-
The EventListener interface is the primary method for handling events. Users implement the EventListener interface and register their listener on an EventTarget using the AddEventListener method. The users should also remove their EventListener from its EventTarget after they have completed using the listener. When a Node is copied using the cloneNode method the EventListeners attached to the source Node are not attached to the copied Node. If the user wishes the same EventListeners to be added to the newly created copy the user must add them manually. IDL Definition // Introduced in DOM Level 2: interface EventListener { void handleEvent(in Event evt); };
Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)
The EventListener method is not supported. Similar functionality is provided by the attachEvent(sEvent, fpNotify) and detachEvent(sEvent, fpNotify) scripting methods.
When an event is cloned, the source node is automatically attached to the cloned event.
V0014:
-
handleEvent This method is called whenever an event occurs of the type for which the EventListener interface was registered. Parameters evt of type Event The Event contains contextual information about the event. It also contains the stopPropagation and preventDefault methods which are used in determining the event's flow and default action. No Return Value No Exceptions
Quirks Mode, IE7 Mode, IE8 Mode, IE9 Mode, IE10 Mode, and IE11 Mode (All Versions)
The handleEvent method is not supported.