TheEventTarget
interface is implemented by allNodes
in an implementation which supports the DOM Event Model. Therefore, this interface can be obtained by using binding-specific casting methods on an instance of theNode
interface. The interface allows registration and removal ofEventListeners
on anEventTarget
and dispatch of events to thatEventTarget
.
This method allows the registration of event listeners on the event target. If anEventListener
is added to anEventTarget
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 identicalEventListener
s are registered on the sameEventTarget
with the same parameters the duplicate instances are discarded. They do not cause theEventListener
to be called twice and since they are discarded they do not need to be removed with theremoveEventListener
method.
The event type for which the user is registering
Thelistener
parameter takes an interface implemented by the user which contains the methods to be called when the event occurs.
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 registeredEventListener
before being dispatched to anyEventTargets
beneath them in the tree. Events which are bubbling upward through the tree will not trigger anEventListener
designated to use capture.
This method allows the removal of event listeners from the event target. If anEventListener
is removed from anEventTarget
while it is processing an event, it will not be triggered by the current actions.EventListener
s can never be invoked after being removed.
CallingremoveEventListener
with arguments which do not identify any currently registeredEventListener
on theEventTarget
has no effect.
Specifies the event type of theEventListener
being removed.
TheEventListener
parameter indicates theEventListener
to be removed.
Specifies whether theEventListener
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.
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 theEventTarget
on whichdispatchEvent
is called.
Specifies the event type, behavior, and contextual information to be used in processing the event.
The return value ofdispatchEvent
indicates whether any of the listeners which handled the event calledpreventDefault
. IfpreventDefault
was called the value is false, else the value is true.
UNSPECIFIED_EVENT_TYPE_ERR: Raised if theEvent
's type was not specified by initializing the event beforedispatchEvent
was called. Specification of theEvent
's type asnull
or an empty string will also trigger this exception.
TheEventListener
interface is the primary method for handling events. Users implement theEventListener
interface and register their listener on anEventTarget
using theAddEventListener
method. The users should also remove theirEventListener
from itsEventTarget
after they have completed using the listener.
When aNode
is copied using thecloneNode
method theEventListener
s attached to the sourceNode
are not attached to the copiedNode
. If the user wishes the sameEventListener
s to be added to the newly created copy the user must add them manually.
This method is called whenever an event occurs of the type for which theEventListener
interface was registered.
TheEvent
contains contextual information about the event. It also contains thestopPropagation
andpreventDefault
methods which are used in determining the event's flow and default action.
TheEvent
interface is used to provide contextual information about an event to the handler processing the event. An object which implements theEvent
interface is generally passed as the first parameter to an event handler. More specific context information is passed to event handlers by deriving additional interfaces fromEvent
which contain information directly relating to the type of event they accompany. These derived interfaces are also implemented by the object passed to the event listener.
An integer indicating which phase of event flow is being processed.
The current event phase is the capturing phase.
The event is currently being evaluated at the targetEventTarget
.
The current event phase is the bubbling phase.
The name of the event (case-insensitive). The name must be an
Used to indicate theEventTarget
to which the event was originally dispatched.
Used to indicate theEventTarget
whoseEventListeners
are currently being processed. This is particularly useful during capturing and bubbling.
Used to indicate which phase of event flow is currently being evaluated.
Used to indicate whether or not an event is a bubbling event. If the event can bubble the value is true, else the value is false.
Used to indicate whether or not an event can have its default action prevented. If the default action can be prevented the value is true, else the value is false.
Used to specify the time (in milliseconds relative to the epoch) at which the event was created. Due to the fact that some systems may not provide this information the value oftimeStamp
may be not available for all events. When not available, a value of 0 will be returned. Examples of epoch time are the time of the system start or 0:0:0 UTC 1st January 1970.
ThestopPropagation
method is used prevent further propagation of an event during event flow. If this method is called by anyEventListener
the event will cease propagating through the tree. The event will complete dispatch to all listeners on the currentEventTarget
before event flow stops. This method may be used during any stage of event flow.
If an event is cancelable, thepreventDefault
method is used to signify that the event is to be canceled, meaning any default action normally taken by the implementation as a result of the event will not occur. If, during any stage of event flow, thepreventDefault
method is called the event is canceled. Any default action associated with the event will not occur. Calling this method for a non-cancelable event has no effect. OncepreventDefault
has been called it will remain in effect throughout the remainder of the event's propagation. This method may be used during any stage of event flow.
TheinitEvent
method is used to initialize the value of anEvent
created through theDocumentEvent
interface. This method may only be called before theEvent
has been dispatched via thedispatchEvent
method, though it may be called multiple times during that phase if necessary. If called multiple times the final invocation takes precedence. If called from a subclass ofEvent
interface only the values specified in theinitEvent
method are modified, all other attributes are left unchanged.
Specifies the event type. This type may be any event type currently defined in this specification or a new event type.. The string must be an
Any new event type must not begin with any upper, lower, or mixed case version of the string "DOM". This prefix is reserved for future DOM event sets. It is also strongly recommended that third parties adding their own events use their own prefix to avoid confusion and lessen the probability of conflicts with other new events.
Specifies whether or not the event can bubble.
Specifies whether or not the event's default action can be prevented.
Event operations may throw anEventException
as specified in their method descriptions.
An integer indicating the type of error generated.
If theEvent
's type was not specified by initializing the event before the method was called. Specification of the Event's type asnull
or an empty string will also trigger this exception.
TheDocumentEvent
interface provides a mechanism by which the user can create an Event of a type supported by the implementation. It is expected that theDocumentEvent
interface will be implemented on the same object which implements theDocument
interface in an implementation which supports the Event model.
TheeventType
parameter specifies the type ofEvent
interface to be created. If theEvent
interface specified is supported by the implementation this method will return a newEvent
of the interface type requested. If theEvent
is to be dispatched via thedispatchEvent
method the appropriate event init method must be called after creation in order to initialize theEvent
's values. As an example, a user wishing to synthesize some kind ofUIEvent
would callcreateEvent
with the parameter "UIEvents". TheinitUIEvent
method could then be called on the newly createdUIEvent
to set the specific type of UIEvent to be dispatched and set its context information.
ThecreateEvent
method is used in creatingEvent
s when it is either inconvenient or unnecessary for the user to create anEvent
themselves. In cases where the implementation providedEvent
is insufficient, users may supply their ownEvent
implementations for use with thedispatchEvent
method.
The newly createdEvent
NOT_SUPPORTED_ERR: Raised if the implementation does not support the type ofEvent
interface requested
TheUIEvent
interface provides specific contextual information associated with User Interface events.
Theview
attribute identifies theAbstractView
from which the event was generated.
Specifies some detail information about theEvent
, depending on the type of event.
TheinitUIEvent
method is used to initialize the value of aUIEvent
created through theDocumentEvent
interface. This method may only be called before theUIEvent
has been dispatched via thedispatchEvent
method, though it may be called multiple times during that phase if necessary. If called multiple times, the final invocation takes precedence.
Specifies the event type.
Specifies whether or not the event can bubble.
Specifies whether or not the event's default action can be prevented.
Specifies theEvent
'sAbstractView
.
Specifies theEvent
's detail.
TheMouseEvent
interface provides specific contextual information associated with Mouse events.
Thedetail
attribute inherited fromUIEvent
indicates the number of times a mouse button has been pressed and released over the same screen location during a user action. The attribute value is 1 when the user begins this action and increments by 1 for each full sequence of pressing and releasing. If the user moves the mouse between the mousedown and mouseup the value will be set to 0, indicating that no click is occurring.
In the case of nested elements mouse events are always targeted at the most deeply nested element. Ancestors of the targeted element may use bubbling to obtain notification of mouse events which occur within its descendent elements.
The horizontal coordinate at which the event occurred relative to the origin of the screen coordinate system.
The vertical coordinate at which the event occurred relative to the origin of the screen coordinate system.
The horizontal coordinate at which the event occurred relative to the DOM implementation's client area.
The vertical coordinate at which the event occurred relative to the DOM implementation's client area.
Used to indicate whether the 'ctrl' key was depressed during the firing of the event.
Used to indicate whether the 'shift' key was depressed during the firing of the event.
Used to indicate whether the 'alt' key was depressed during the firing of the event. On some platforms this key may map to an alternative key name.
Used to indicate whether the 'meta' key was depressed during the firing of the event. On some platforms this key may map to an alternative key name.
During mouse events caused by the depression or release of a mouse button,button
is used to indicate which mouse button changed state. The values forbutton
range from zero to indicate the left button of the mouse, one to indicate the middle button if present, and two to indicate the right button. For mice configured for left handed use in which the button actions are reversed the values are instead read from right to left.
Used to identify a secondaryEventTarget
related to a UI event. Currently this attribute is used with the mouseover event to indicate theEventTarget
which the pointing device exited and with the mouseout event to indicate theEventTarget
which the pointing device entered.
TheinitMouseEvent
method is used to initialize the value of aMouseEvent
created through theDocumentEvent
interface. This method may only be called before theMouseEvent
has been dispatched via thedispatchEvent
method, though it may be called multiple times during that phase if necessary. If called multiple times, the final invocation takes precedence.
Specifies the event type.
Specifies whether or not the event can bubble.
Specifies whether or not the event's default action can be prevented.
Specifies theEvent
'sAbstractView
.
Specifies theEvent
's mouse click count.
Specifies theEvent
's screen x coordinate
Specifies theEvent
's screen y coordinate
Specifies theEvent
's client x coordinate
Specifies theEvent
's client y coordinate
Specifies whether or not control key was depressed during theEvent
.
Specifies whether or not alt key was depressed during theEvent
.
Specifies whether or not shift key was depressed during theEvent
.
Specifies whether or not meta key was depressed during theEvent
.
Specifies theEvent
's mouse button.
Specifies theEvent
's relatedEventTarget
.
TheMutationEvent
interface provides specific contextual information associated with Mutation events.
An integer indicating in which way theAttr
was changed.
TheAttr
was modified in place.
TheAttr
was just added.
TheAttr
was just removed.
relatedNode
is used to identify a secondary node related to a mutation event. For example, if a mutation event is dispatched to a node indicating that its parent has changed, therelatedNode
is the changed parent. If an event is instead dispatched to a subtree indicating a node was changed within it, therelatedNode
is the changed node. In the case of the DOMAttrModified event it indicates theAttr
node which was modified, added, or removed.
prevValue
indicates the previous value of theAttr
node in DOMAttrModified events, and of theCharacterData
node in DOMCharDataModified events.
newValue
indicates the new value of theAttr
node in DOMAttrModified events, and of theCharacterData
node in DOMCharDataModified events.
attrName
indicates the name of the changedAttr
node in a DOMAttrModified event.
attrChange
indicates the type of change which triggered the DOMAttrModified event. The values can beMODIFICATION
,ADDITION
, orREMOVAL
.
TheinitMutationEvent
method is used to initialize the value of aMutationEvent
created through theDocumentEvent
interface. This method may only be called before theMutationEvent
has been dispatched via thedispatchEvent
method, though it may be called multiple times during that phase if necessary. If called multiple times, the final invocation takes precedence.
Specifies the event type.
Specifies whether or not the event can bubble.
Specifies whether or not the event's default action can be prevented.
Specifies theEvent
's related Node.
Specifies theEvent
'sprevValue
attribute. This value may be null.
Specifies theEvent
'snewValue
attribute. This value may be null.
Specifies theEvent
'sattrName
attribute. This value may be null.
Specifies theEvent
'sattrChange
attribute