previous   next   contents   objects   index

WD-DOM-Level-2-19990923

6. Document Object Model Events

Editors
Tom Pixley, Netscape Communications Corporation

Table of contents

6.1. Overview of the DOM Level 2 Event Model

The DOM Level 2 Event Model is designed with two main goals. The first goal is the design of a generic event system which allows registration of event handlers, describes event flow through a tree structure, and provides basic contextual information for each event. Additionally, the specification will provide standard sets of events for user interface control and document mutation notifications, including defined contextual information for each of these event sets.

The second goal of the event model is to provide a common subset of the current event systems used in DOM Level 0 browsers. This is intended to foster interoperability of existing scripts and content. It is not expected that this goal will be met with full backwards compatibility. However, the specification attempts to achieve this when possible.

The following sections of the Event Model specification define both the specification for the DOM Event Model and a number of compliant event sets designed for use within the model. The Event Model consists of the two sections on event propagation and event listener registration and the Event interface. A DOM consumer can use the hasFeature of the DOMImplementation interface to determine whether the Event Model has been implemented by a DOM implementation. The feature string for the Event Model is "Events". The existence within an implementation of each of the individual event sets can also be queried using the hasFeature method. Each event set describes its own feature string in the event set listing.

6.1.1. Terminology

UI events
User interface events. These events are generated by user interaction through an external device (mouse, keyboard, etc.)
UI Logical events
Device independent user interface events such as focus change messages or element triggering notifications.
Mutation events
Events caused by any action which modifies the structure of the document.
Capturing
The process by which an event can be handled by one of the event's target's ancestors before being handled by the event's target.
Bubbling
The process by which an event propagates upward through its ancestors after being handled by the event's target.
Cancelable
A designation for events which indicates that upon handling the event the client may choose to prevent the DOM implementation from processing any default action associated with the event.

6.2. Description of event flow

Event flow is the process through which the an event originates from the DOM implementation and is passed into the Document Object Model. The methods of event capture and event bubbling, along with various event listener registration techniques, allow the event to then be handled in a number of ways. It can be handled locally at the EventTarget level or centrally from an EventTarget higher in the document tree.

6.2.1. Basic event flow

Each event has an EventTarget toward which the event is directed by the DOM implementation. This EventTarget is specified in the Event's target attribute. When the event reaches the target, any event listeners registered on the EventTarget are triggered. Although all EventListeners on the EventTarget are guaranteed to receive the event, no specification is made as to the order in which they will receive the event with regards to the other EventListeners on the EventTarget. If neither event capture or event bubbling are in use for that particular event, the event flow process will complete after all listeners have been triggered. If event capture or event bubbling is in use, the event flow will be modified as described in the sections below.

Any exceptions thrown inside an EventListener will not stop propagation of the event. It will continue processing any additional EventListener in the described manner.

6.2.2. Event Capture

Event capture is the process by which an EventListener registered on an ancestor of the event's target can intercept events of a given type before they are received by the event's target. Capture operates from the top of the tree downward, making it the symmetrical opposite of bubbling which is described below.

An EventListener being registered on an EventTarget may choose to have that EventListener capture events by specifying the useCapture parameter of the addEventListener method to be true. Thereafter, when an event of the given type is dispatched toward a descendant of the capturing object, the event will trigger any capturing event listeners of the appropriate type which exist in the direct line between the top of the document and the event's target. This downward propagation continues until the event's target is reached. A capturing EventListener will not be triggered by events dispatched directly the the EventTarget upon which it is registered.

If the capturing EventListener wishes to prevent further processing of the event, either later in the capture phase or during bubbling, it may call the preventCapture method of the Event interface. This will prevent further dispatch of the event to additional EventTargets lower in the tree structure, although additional EventListeners registered at the same hierarchy level will still receive the event. Once an event's preventCapture method has been called, further calls to that method have no additional effect. If no additional capturers exist and preventCapture has not been called, the event triggers the appropriate EventListeners on the target itself.

Although event capture is similar to the delegation based event model in which all interested parties register their listeners directly on the target about which they wish to receive notifications, it is different in two important respects. First, event capture only allows interception of events which are targeted at descendants of the capturing Node. It does not allow interception of events targeted to the capturer's ancestors, its siblings, or its sibling's descendants. Secondly, event capture is not specified for a single Node, it is specified for a specific type of event. Once specified, event capture intercepts all events of the specified type targeted toward any of the capturer's descendants.

6.2.3. Event bubbling

Events which are designated as bubbling will initially proceed with the same event flow as non-bubbling events. The event is dispatched to its target Node and any event listeners found there are triggered. Bubbling events will then trigger any additional event listeners found by following the Node's parent chain upward, checking for any event listeners registered on each successive Node. This upward propagation will continue up to and including the Document.

Any event handler may choose to prevent continuation of the bubbling process by calling the preventBubble method of the Event interface. If any EventListener calls this method, all additional EventListeners on the current EventTarget will be triggered but bubbling will cease at that level. Only one call to preventBubble is required to prevent further bubbling.

6.2.4. Event cancelation

Some events are specified as cancelable. For these events, the DOM implementation generally has a default action associated with the event. Before processing these events, the implementation must check for event listeners registered to receive the event and dispatch the event to those listeners. These listeners then have the option of canceling the implementation's default action or allowing the default action to proceed. Cancelation is accomplished by calling the Event's preventDefault method. If one or more EventListeners call preventDefault during any phase of event flow the default action will be canceled.

6.3. Event listener registration

6.3.1. Event registration interfaces

Interface EventTarget (introduced in DOM Level 2)

The EventTarget interface is implemented by all Nodes in an implementation which supports the DOM Event Model. The interface allows registration and removal of EventListeners on an EventTarget and dispatch of events to that EventTarget.


IDL Definition
// Introduced in DOM Level 2:
interface EventTarget {
  void               addEventListener(in DOMString type, 
                                      in EventListener listener, 
                                      in boolean useCapture);
  void               removeEventListener(in DOMString type, 
                                         in EventListener listener, 
                                         in boolean useCapture);
  boolean            dispatchEvent(in Event evt)
                                        raises(DOMException);
};

Methods
addEventListener
This method allows the registration of event listeners on the event target.
Parameters

DOMString

type

The event type for which the user is registering

EventListener

listener

The listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs.

boolean

useCapture

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.

If an EventListener is added to an EventTarget which is currently processing an event the new listener will not be triggered by the current event.

No Return Value
No Exceptions

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 complete its current actions but will not be triggered again during any later stages of event flow.
If an EventListener is removed from an EventTarget which is currently processing an event the removed listener will still be triggered by the current event.
Parameters

DOMString

type

Specifies the event type of the EventListener being removed.

EventListener

listener

The EventListener parameter indicates the EventListener to be removed.

boolean

useCapture

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

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

Event

evt

Specifies 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

DOMException

UNSPECIFIED_EVENT_TYPE: Raised if the Event's type was not specified by initializing the event before dispatchEvent was called.

Interface EventListener (introduced in DOM Level 2)

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.


IDL Definition
// Introduced in DOM Level 2:
interface EventListener {
  void               handleEvent(in Event evt);
};

Methods
handleEvent
This method is called whenever an event occurs of the type for which the EventListener interface was registered.
Parameters

Event

evt

The Event contains contextual information about the event. It also contains the preventDefault, preventBubble, and preventCapture methods which are used in determining the event's flow and default action.

No Return Value
No Exceptions

6.3.2. Interaction with HTML 4.0 event listeners

In HTML 4.0, event listeners were specified as attributes of an element. As such, registration of a second event listener of the same type would replace the first listener. The DOM Event Model allows registration of multiple event listeners on a single Node. To achieve this, event listeners are no longer stored as attribute values.

In order to achieve compatibility with HTML 4.0, implementors may view the setting of attributes which represent event handlers as the creation and registration of an EventListener on the Node. The value of useCapture defaults to false. This EventListener behaves in the same manner as any other EventListeners which may be registered on the EventTarget. If the attribute representing the event listener is changed, this may be viewed as the removal of the previously registered EventListener and the registration of a new one. No technique is provided to allow HTML 4.0 event listeners access to the context information defined for each event.

6.4. Event interface

Interface Event (introduced in DOM Level 2)

The Event interface is used to provide contextual information about an event to the handler processing the event. An object which implements the Event 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 from Event 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.


IDL Definition
// Introduced in DOM Level 2:
interface Event {
  // PhaseType
  const unsigned short      BUBBLING_PHASE                 = 1;
  const unsigned short      CAPTURING_PHASE                = 2;
  const unsigned short      AT_TARGET                      = 3;

  readonly attribute DOMString        type;
  readonly attribute EventTarget      target;
  readonly attribute Node             currentNode;
  readonly attribute unsigned short   eventPhase;
  readonly attribute boolean          bubbles;
  readonly attribute boolean          cancelable;
  void               preventBubble();
  void               preventCapture();
  void               preventDefault();
  void               initEvent(in DOMString eventTypeArg, 
                               in boolean canBubbleArg, 
                               in boolean cancelableArg);
};

Definition group PhaseType

An integer indicating which phase of event flow is being processed.

Defined Constants
BUBBLING_PHASE The current event phase is the bubbling phase.
CAPTURING_PHASE The current event phase is the capturing phase.
AT_TARGET The event is currently being evaluated at the target node.
Attributes
type of type DOMString, readonly
The type property represents the event name as a string property.

target of type EventTarget, readonly
The target property indicates the EventTarget to which the event was originally dispatched.

currentNode of type Node, readonly
The currentNode property indicates the Node whose EventListeners are currently being processed. This is particularly useful during capturing and bubbling.

eventPhase of type unsigned short, readonly
The eventPhase property indicates which phase of event flow is currently being evaluated.

bubbles of type boolean, readonly
The bubbles property indicates whether or not an event is a bubbling event. If the event can bubble the value is true, else the value is false.

cancelable of type boolean, readonly
The cancelable property indicates 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.

Methods
preventBubble
The preventBubble method is used to end the bubbling phase of event flow. If this method is called by any EventListeners registered on the same EventTarget during bubbling, the bubbling phase will cease at that level and the event will not be propagated upward within the tree.
No Parameters
No Return Value
No Exceptions

preventCapture
The preventCapture method is used to end the capturing phase of event flow. If this method is called by any EventListeners registered on the same EventTarget during capturing, the capturing phase will cease at that level and the event will not be propagated any further down.
No Parameters
No Return Value
No Exceptions

preventDefault
If an event is cancelable, the preventCapture 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, the preventDefault 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. Once preventDefault has been called it will remain in effect throughout the remainder of the event's propagation.
No Parameters
No Return Value
No Exceptions

initEvent
Parameters

DOMString

eventTypeArg

Specifies the event type. This type may be any event type currently defined in this specification or a new event type. 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.

boolean

canBubbleArg

Specifies whether or not the event can bubble.

boolean

cancelableArg

Specifies whether or not the event's default action can be prevented.

No Return Value
No Exceptions

6.5. DocumentEvent interface

Interface DocumentEvent (introduced in DOM Level 2)

The DocumentEvent interface provides a mechanism by which the a user can create an Event of a type supported by the implementation. It is expected that the DocumentEvent interface will be implemented on the same object which implements the Document interface in an implementation which supports the Event model.


IDL Definition
// Introduced in DOM Level 2:
interface DocumentEvent {
  Event              createEvent(in DOMString type)
                                        raises(DOMException);
};

Methods
createEvent
Parameters

DOMString

type

The type paramater specifies the type of Event to be created. If the Event type specified is supported by the implementation this method will return a new Event of the type requested. If the Event is to be dispatched via the dispatchEvent method the appropriate event init method must be called after creation in order to initialize the Event's values.

Return Value

Event

The newly created Event

Exceptions

DOMException

UNSUPPORTED_EVENT_TYPE: Raised if the implementation does not support the type of Event requested

6.6. Event set definitions

The DOM Level 2 Event Model allows a DOM implementation to support multiple sets of events. The model has been designed to allow addition of new event sets as is required. The DOM will not attempt to define all possible events. For purposes of interoperability, the DOM will define a set of user interface events including lower level device dependent events, a set of UI logical events, and a set of document mutation events.

6.6.1. User Interface event types

The User Interface event set is composed of events listed in HTML 4.0 and additional events which are supported in DOM Level 0 browsers.

A DOM consumer can use the hasFeature of the DOMImplementation interface to determine whether the User Interface event set has been implemented by a DOM implementation. The feature string for this event set is "UIEvents".

Interface UIEvent (introduced in DOM Level 2)

The UIEvent interface provides specific contextual information associated with User Interface events.


IDL Definition
// Introduced in DOM Level 2:
interface UIEvent : Event {
  readonly attribute views::AbstractView  view;
  readonly attribute unsigned short   detail;
  void               initUIEvent(in DOMString typeArg, 
                                 in boolean canBubbleArg, 
                                 in boolean cancelableArg, 
                                 in views::AbstractView viewArg, 
                                 in unsigned short detailArg);
};

Attributes
view of type views::AbstractView, readonly
The view attribute identifies the AbstractView from which the event was generated.

detail of type unsigned short, readonly
Specifies some detail information about the Event, depending on the type of event.

Methods
initUIEvent
Parameters

DOMString

typeArg

Specifies the event type.

boolean

canBubbleArg

Specifies whether or not the event can bubble.

boolean

cancelableArg

Specifies whether or not the event's default action can be prevent.

views::AbstractView

viewArg

Specifies the Event's AbstractView.

unsigned short

detailArg

Specifies the Event's detail.

No Return Value
No Exceptions

The different types of such events that can occur are:

resize
The resize event occurs when a document view is resized.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: None
scroll
The scroll event occurs when a document view is scrolled.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: None
focusin
The focusin event occurs when a node receives focus, for instance via a pointing device being moved onto an element or by tabbing navigation to the element. Unlike the HTML event focus, focusin can be applied to any node, not just FORM controls.
  • Bubbles: No
  • Cancelable: No
  • Context Info: None
focusout
The focusout event occurs when a node loses focus, for instance via a pointing device being moved out of an element or by tabbing navigation out of the element. Unlike the HTML event blur, focusout can be applied to any node, not just FORM controls.
  • Bubbles: No
  • Cancelable: No
  • Context Info: None
gainselection
The gainselection event occurs when a node or part of it is selected (unlike the HTML event select, it can be applied to any element, not just HTML FORM controls). For each selected node a gainselection event, which can be handled locally or thru bubbling by a root node selection handler, is generated.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: range
loseselection
The loseselection event occurs when a node or part of it is deselected, for example because the user selects something else.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: range
activate
The activate event occurs when an element is activated, for instance, thru a mouse click or a keypress. A numerical argument is provided to give an indication of the type of activation that occurs: 1 for a simple activation (e.g. a simple click or Enter), 2 for hyperactivation (for instance a double click or Shift Enter).
  • Bubbles: Yes
  • Cancelable: Yes
  • Context Info: detail (the numerical value)

6.6.2. Mouse event types

The Mouse event set is composed of events listed in HTML 4.0 and additional events which are supported in DOM Level 0 browsers. This event set is specifically for use with mouse input devices.

A DOM consumer can use the hasFeature of the DOMImplementation interface to determine whether the User Interface event set has been implemented by a DOM implementation. The feature string for this event set is "MouseEvents".

Interface MouseEvent (introduced in DOM Level 2)

The MouseEvent interface provides specific contextual information associated with Mouse events.

The detail attribute inherited from UIEvent 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.


IDL Definition
// Introduced in DOM Level 2:
interface MouseEvent : UIEvent {
  readonly attribute long             screenX;
  readonly attribute long             screenY;
  readonly attribute long             clientX;
  readonly attribute long             clientY;
  readonly attribute boolean          ctrlKey;
  readonly attribute boolean          shiftKey;
  readonly attribute boolean          altKey;
  readonly attribute boolean          metaKey;
  readonly attribute unsigned short   button;
  readonly attribute Node             relatedNode;
  void               initMouseEvent(in DOMString typeArg, 
                                    in boolean canBubbleArg, 
                                    in boolean cancelableArg, 
                                    in views::AbstractView viewArg, 
                                    in unsigned short detailArg, 
                                    in long screenXArg, 
                                    in long screenYArg, 
                                    in long clientXArg, 
                                    in long clientYArg, 
                                    in boolean ctrlKeyArg, 
                                    in boolean altKeyArg, 
                                    in boolean shiftKeyArg, 
                                    in boolean metaKeyArg, 
                                    in unsigned short buttonArg, 
                                    in Node relatedNodeArg);
};

Attributes
screenX of type long, readonly
screenX indicates the horizontal coordinate at which the event occurred in relative to the origin of the screen coordinate system.

screenY of type long, readonly
screenY indicates the vertical coordinate at which the event occurred relative to the origin of the screen coordinate system.

clientX of type long, readonly
clientX indicates the horizontal coordinate at which the event occurred relative to the DOM implementation's client area.

clientY of type long, readonly
clientY indicates the vertical coordinate at which the event occurred relative to the DOM implementation's client area.

ctrlKey of type boolean, readonly
ctrlKey indicates whether the 'ctrl' key was depressed during the firing of the event.

shiftKey of type boolean, readonly
shiftKey indicates whether the 'shift' key was depressed during the firing of the event.

altKey of type boolean, readonly
altKey indicates whether the 'alt' key was depressed during the firing of the event. On some platforms this key may map to an alternative key name.

metaKey of type boolean, readonly
metaKey indicates whether the 'meta' key was depressed during the firing of the event. On some platforms this key may map to an alternative key name.

button of type unsigned short, readonly
During mouse events caused by the depression or release of a mouse button, button is used to indicate which mouse button changed state.

relatedNode of type Node, readonly
relatedNode is used to identify a secondary node related to a UI event.

Methods
initMouseEvent
Parameters

DOMString

typeArg

Specifies the event type.

boolean

canBubbleArg

Specifies whether or not the event can bubble.

boolean

cancelableArg

Specifies whether or not the event's default action can be prevent.

views::AbstractView

viewArg

Specifies the Event's AbstractView.

unsigned short

detailArg

Specifies the Event's mouse click count.

long

screenXArg

Specifies the Event's screen x coordinate

long

screenYArg

Specifies the Event's screen y coordinate

long

clientXArg

Specifies the Event's client x coordinate

long

clientYArg

Specifies the Event's client y coordinate

boolean

ctrlKeyArg

Specifies whether or not control key was depressed during the Event.

boolean

altKeyArg

Specifies whether or not alt key was depressed during the Event.

boolean

shiftKeyArg

Specifies whether or not shift key was depressed during the Event.

boolean

metaKeyArg

Specifies whether or not meta key was depressed during the Event.

unsigned short

buttonArg

Specifies the Event's mouse button.

Node

relatedNodeArg

Specifies the Event's related Node.

No Return Value
No Exceptions

The different types of Mouse events that can occur are:

click
The click event occurs when the pointing device button is clicked over an element. A click is defined as a mousedown and mouseup over the same screen location. The sequence of these events is:
    mousedown
    mouseup
    click
    
If multiple clicks occur at the same screen location, the sequence repeats with the detail attribute incrementing with each repetition. This event is valid for most elements.
  • Bubbles: Yes
  • Cancelable: Yes
  • Context Info: screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey, button, detail
mousedown
The mousedown event occurs when the pointing device button is pressed over an element. This event is valid for most elements.
  • Bubbles: Yes
  • Cancelable: Yes
  • Context Info: screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey, button, detail
mouseup
The mouseup event occurs when the pointing device button is released over an element. This event is valid for most elements.
  • Bubbles: Yes
  • Cancelable: Yes
  • Context Info: screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey, button, detail
mouseover
The mouseover event occurs when the pointing device is moved onto an element. This event is valid for most elements.
  • Bubbles: Yes
  • Cancelable: Yes
  • Context Info: screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey, relatedNode
mousemove
The mousemove event occurs when the pointing device is moved while it is over an element. This event is valid for most elements.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey
mouseout
The mouseout event occurs when the pointing device is moved away from an element. This event is valid for most elements..
  • Bubbles: Yes
  • Cancelable: Yes
  • Context Info: screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey, relatedNode

6.6.3. Key event types

The Key event set is composed of events listed in HTML 4.0 and additional events which are supported in DOM Level 0 browsers. This event set is specifically for use with keyboard input devices.

A DOM consumer can use the hasFeature of the DOMImplementation interface to determine whether the Key event set has been implemented by a DOM implementation. The feature string for this event set is "KeyEvents".

Interface KeyEvent (introduced in DOM Level 2)

The KeyEvent interface provides specific contextual information associated with Key events.


IDL Definition
// Introduced in DOM Level 2:
interface KeyEvent : UIEvent {
  // VirtualKeyCode
  const unsigned long       CHAR_UNDEFINED                 = 0x0FFFF;
  const unsigned long       DOM_VK_0                       = 0x30;
  const unsigned long       DOM_VK_1                       = 0x31;
  const unsigned long       DOM_VK_2                       = 0x32;
  const unsigned long       DOM_VK_3                       = 0x33;
  const unsigned long       DOM_VK_4                       = 0x34;
  const unsigned long       DOM_VK_5                       = 0x35;
  const unsigned long       DOM_VK_6                       = 0x36;
  const unsigned long       DOM_VK_7                       = 0x37;
  const unsigned long       DOM_VK_8                       = 0x38;
  const unsigned long       DOM_VK_9                       = 0x39;
  const unsigned long       DOM_VK_A                       = 0x41;
  const unsigned long       DOM_VK_ACCEPT                  = 0x1E;
  const unsigned long       DOM_VK_ADD                     = 0x6B;
  const unsigned long       DOM_VK_AGAIN                   = 0xFFC9;
  const unsigned long       DOM_VK_ALL_CANDIDATES          = 0x0100;
  const unsigned long       DOM_VK_ALPHANUMERIC            = 0x00F0;
  const unsigned long       DOM_VK_ALT                     = 0x12;
  const unsigned long       DOM_VK_ALT_GRAPH               = 0xFF7E;
  const unsigned long       DOM_VK_AMPERSAND               = 0x96;
  const unsigned long       DOM_VK_ASTERISK                = 0x97;
  const unsigned long       DOM_VK_AT                      = 0x0200;
  const unsigned long       DOM_VK_B                       = 0x42;
  const unsigned long       DOM_VK_BACK_QUOTE              = 0xC0;
  const unsigned long       DOM_VK_BACK_SLASH              = 0x5C;
  const unsigned long       DOM_VK_BACK_SPACE              = 0x08;
  const unsigned long       DOM_VK_BRACELEFT               = 0xA1;
  const unsigned long       DOM_VK_BRACERIGHT              = 0xA2;
  const unsigned long       DOM_VK_C                       = 0x43;
  const unsigned long       DOM_VK_CANCEL                  = 0x03;
  const unsigned long       DOM_VK_CAPS_LOCK               = 0x14;
  const unsigned long       DOM_VK_CIRCUMFLEX              = 0x0202;
  const unsigned long       DOM_VK_CLEAR                   = 0x0C;
  const unsigned long       DOM_VK_CLOSE_BRACKET           = 0x5D;
  const unsigned long       DOM_VK_CODE_INPUT              = 0x0102;
  const unsigned long       DOM_VK_COLON                   = 0x0201;
  const unsigned long       DOM_VK_COMMA                   = 0x2C;
  const unsigned long       DOM_VK_COMPOSE                 = 0xFF20;
  const unsigned long       DOM_VK_CONTROL                 = 0x11;
  const unsigned long       DOM_VK_CONVERT                 = 0x1C;
  const unsigned long       DOM_VK_COPY                    = 0xFFCD;
  const unsigned long       DOM_VK_CUT                     = 0xFFD1;
  const unsigned long       DOM_VK_D                       = 0x44;
  const unsigned long       DOM_VK_DEAD_ABOVEDOT           = 0x86;
  const unsigned long       DOM_VK_DEAD_ABOVERING          = 0x88;
  const unsigned long       DOM_VK_DEAD_ACUTE              = 0x81;
  const unsigned long       DOM_VK_DEAD_BREVE              = 0x85;
  const unsigned long       DOM_VK_DEAD_CARON              = 0x8A;
  const unsigned long       DOM_VK_DEAD_CEDILLA            = 0x8B;
  const unsigned long       DOM_VK_DEAD_CIRCUMFLEX         = 0x82;
  const unsigned long       DOM_VK_DEAD_DIAERESIS          = 0x87;
  const unsigned long       DOM_VK_DEAD_DOUBLEACUTE        = 0x89;
  const unsigned long       DOM_VK_DEAD_GRAVE              = 0x80;
  const unsigned long       DOM_VK_DEAD_IOTA               = 0x8D;
  const unsigned long       DOM_VK_DEAD_MACRON             = 0x84;
  const unsigned long       DOM_VK_DEAD_OGONEK             = 0x8C;
  const unsigned long       DOM_VK_DEAD_SEMIVOICED_SOUND   = 0x8F;
  const unsigned long       DOM_VK_DEAD_TILDE              = 0x83;
  const unsigned long       DOM_VK_DEAD_VOICED_SOUND       = 0x8E;
  const unsigned long       DOM_VK_DECIMAL                 = 0x6E;
  const unsigned long       DOM_VK_DELETE                  = 0x7F;
  const unsigned long       DOM_VK_DIVIDE                  = 0x6F;
  const unsigned long       DOM_VK_DOLLAR                  = 0x0203;
  const unsigned long       DOM_VK_DOWN                    = 0x28;
  const unsigned long       DOM_VK_E                       = 0x45;
  const unsigned long       DOM_VK_END                     = 0x23;
  const unsigned long       DOM_VK_ENTER                   = 0x0D;
  const unsigned long       DOM_VK_EQUALS                  = 0x3D;
  const unsigned long       DOM_VK_ESCAPE                  = 0x1B;
  const unsigned long       DOM_VK_EURO_SIGN               = 0x0204;
  const unsigned long       DOM_VK_EXCLAMATION_MARK        = 0x0205;
  const unsigned long       DOM_VK_F                       = 0x46;
  const unsigned long       DOM_VK_F1                      = 0x70;
  const unsigned long       DOM_VK_F10                     = 0x79;
  const unsigned long       DOM_VK_F11                     = 0x7A;
  const unsigned long       DOM_VK_F12                     = 0x7B;
  const unsigned long       DOM_VK_F13                     = 0xF000;
  const unsigned long       DOM_VK_F14                     = 0xF001;
  const unsigned long       DOM_VK_F15                     = 0xF002;
  const unsigned long       DOM_VK_F16                     = 0xF003;
  const unsigned long       DOM_VK_F17                     = 0xF004;
  const unsigned long       DOM_VK_F18                     = 0xF005;
  const unsigned long       DOM_VK_F19                     = 0xF006;
  const unsigned long       DOM_VK_F2                      = 0x71;
  const unsigned long       DOM_VK_F20                     = 0xF007;
  const unsigned long       DOM_VK_F21                     = 0xF008;
  const unsigned long       DOM_VK_F22                     = 0xF009;
  const unsigned long       DOM_VK_F23                     = 0xF00A;
  const unsigned long       DOM_VK_F24                     = 0xF00B;
  const unsigned long       DOM_VK_F3                      = 0x72;
  const unsigned long       DOM_VK_F4                      = 0x73;
  const unsigned long       DOM_VK_F5                      = 0x74;
  const unsigned long       DOM_VK_F6                      = 0x75;
  const unsigned long       DOM_VK_F7                      = 0x76;
  const unsigned long       DOM_VK_F8                      = 0x77;
  const unsigned long       DOM_VK_F9                      = 0x78;
  const unsigned long       DOM_VK_FINAL                   = 0x18;
  const unsigned long       DOM_VK_FIND                    = 0xFFD0;
  const unsigned long       DOM_VK_FULL_WIDTH              = 0x00F3;
  const unsigned long       DOM_VK_G                       = 0x47;
  const unsigned long       DOM_VK_GREATER                 = 0xA0;
  const unsigned long       DOM_VK_H                       = 0x48;
  const unsigned long       DOM_VK_HALF_WIDTH              = 0x00F4;
  const unsigned long       DOM_VK_HELP                    = 0x9C;
  const unsigned long       DOM_VK_HIRAGANA                = 0x00F2;
  const unsigned long       DOM_VK_HOME                    = 0x24;
  const unsigned long       DOM_VK_I                       = 0x49;
  const unsigned long       DOM_VK_INSERT                  = 0x9B;
  const unsigned long       DOM_VK_INVERTED_EXCLAMATION_MARK = 0x0206;
  const unsigned long       DOM_VK_J                       = 0x4A;
  const unsigned long       DOM_VK_JAPANESE_HIRAGANA       = 0x0104;
  const unsigned long       DOM_VK_JAPANESE_KATAKANA       = 0x0103;
  const unsigned long       DOM_VK_JAPANESE_ROMAN          = 0x0105;
  const unsigned long       DOM_VK_K                       = 0x4B;
  const unsigned long       DOM_VK_KANA                    = 0x15;
  const unsigned long       DOM_VK_KANJI                   = 0x19;
  const unsigned long       DOM_VK_KATAKANA                = 0x00F1;
  const unsigned long       DOM_VK_KP_DOWN                 = 0xE1;
  const unsigned long       DOM_VK_KP_LEFT                 = 0xE2;
  const unsigned long       DOM_VK_KP_RIGHT                = 0xE3;
  const unsigned long       DOM_VK_KP_UP                   = 0xE0;
  const unsigned long       DOM_VK_L                       = 0x4C;
  const unsigned long       DOM_VK_LEFT                    = 0x25;
  const unsigned long       DOM_VK_LEFT_PARENTHESIS        = 0x0207;
  const unsigned long       DOM_VK_LESS                    = 0x99;
  const unsigned long       DOM_VK_M                       = 0x4D;
  const unsigned long       DOM_VK_META                    = 0x9D;
  const unsigned long       DOM_VK_MINUS                   = 0x2D;
  const unsigned long       DOM_VK_MODECHANGE              = 0x1F;
  const unsigned long       DOM_VK_MULTIPLY                = 0x6A;
  const unsigned long       DOM_VK_N                       = 0x4E;
  const unsigned long       DOM_VK_NONCONVERT              = 0x1D;
  const unsigned long       DOM_VK_NUM_LOCK                = 0x90;
  const unsigned long       DOM_VK_NUMBER_SIGN             = 0x0208;
  const unsigned long       DOM_VK_NUMPAD0                 = 0x60;
  const unsigned long       DOM_VK_NUMPAD1                 = 0x61;
  const unsigned long       DOM_VK_NUMPAD2                 = 0x62;
  const unsigned long       DOM_VK_NUMPAD3                 = 0x63;
  const unsigned long       DOM_VK_NUMPAD4                 = 0x64;
  const unsigned long       DOM_VK_NUMPAD5                 = 0x65;
  const unsigned long       DOM_VK_NUMPAD6                 = 0x66;
  const unsigned long       DOM_VK_NUMPAD7                 = 0x67;
  const unsigned long       DOM_VK_NUMPAD8                 = 0x68;
  const unsigned long       DOM_VK_NUMPAD9                 = 0x69;
  const unsigned long       DOM_VK_O                       = 0x4F;
  const unsigned long       DOM_VK_OPEN_BRACKET            = 0x5B;
  const unsigned long       DOM_VK_P                       = 0x50;
  const unsigned long       DOM_VK_PAGE_DOWN               = 0x22;
  const unsigned long       DOM_VK_PAGE_UP                 = 0x21;
  const unsigned long       DOM_VK_PASTE                   = 0xFFCF;
  const unsigned long       DOM_VK_PAUSE                   = 0x13;
  const unsigned long       DOM_VK_PERIOD                  = 0x2E;
  const unsigned long       DOM_VK_PLUS                    = 0x0209;
  const unsigned long       DOM_VK_PREVIOUS_CANDIDATE      = 0x0101;
  const unsigned long       DOM_VK_PRINTSCREEN             = 0x9A;
  const unsigned long       DOM_VK_PROPS                   = 0xFFCA;
  const unsigned long       DOM_VK_Q                       = 0x51;
  const unsigned long       DOM_VK_QUOTE                   = 0xDE;
  const unsigned long       DOM_VK_QUOTEDBL                = 0x98;
  const unsigned long       DOM_VK_R                       = 0x52;
  const unsigned long       DOM_VK_RIGHT                   = 0x27;
  const unsigned long       DOM_VK_RIGHT_PARENTHESIS       = 0x020A;
  const unsigned long       DOM_VK_ROMAN_CHARACTERS        = 0x00F5;
  const unsigned long       DOM_VK_S                       = 0x53;
  const unsigned long       DOM_VK_SCROLL_LOCK             = 0x91;
  const unsigned long       DOM_VK_SEMICOLON               = 0x3B;
  const unsigned long       DOM_VK_SEPARATER               = 0x6C;
  const unsigned long       DOM_VK_SHIFT                   = 0x10;
  const unsigned long       DOM_VK_SLASH                   = 0x2F;
  const unsigned long       DOM_VK_SPACE                   = 0x20;
  const unsigned long       DOM_VK_STOP                    = 0xFFC8;
  const unsigned long       DOM_VK_SUBTRACT                = 0x6D;
  const unsigned long       DOM_VK_T                       = 0x54;
  const unsigned long       DOM_VK_TAB                     = 0x09;
  const unsigned long       DOM_VK_U                       = 0x55;
  const unsigned long       DOM_VK_UNDEFINED               = 0x0;
  const unsigned long       DOM_VK_UNDERSCORE              = 0x020B;
  const unsigned long       DOM_VK_UNDO                    = 0xFFCB;
  const unsigned long       DOM_VK_UP                      = 0x26;
  const unsigned long       DOM_VK_V                       = 0x56;
  const unsigned long       DOM_VK_W                       = 0x57;
  const unsigned long       DOM_VK_X                       = 0x58;
  const unsigned long       DOM_VK_Y                       = 0x59;
  const unsigned long       DOM_VK_Z                       = 0x5A;

  readonly attribute boolean          ctrlKey;
  readonly attribute boolean          shiftKey;
  readonly attribute boolean          altKey;
  readonly attribute boolean          metaKey;
  readonly attribute unsigned long    keyCode;
  readonly attribute unsigned long    charCode;
  void               initKeyEvent(in DOMString typeArg, 
                                  in boolean canBubbleArg, 
                                  in boolean cancelableArg, 
                                  in boolean ctrlKeyArg, 
                                  in boolean altKeyArg, 
                                  in boolean shiftKeyArg, 
                                  in boolean metaKeyArg, 
                                  in unsigned long keyCodeArg, 
                                  in unsigned long charCodeArg, 
                                  in views::AbstractView viewArg);
};

Definition group VirtualKeyCode

An integer indicating which key was pressed.

Defined Constants
CHAR_UNDEFINED KEY_PRESSED and KEY_RELEASED events which do not map to a valid Unicode character use this for the keyChar value.
DOM_VK_0 VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39)
DOM_VK_1
DOM_VK_2
DOM_VK_3
DOM_VK_4
DOM_VK_5
DOM_VK_6
DOM_VK_7
DOM_VK_8
DOM_VK_9
DOM_VK_A VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A)
DOM_VK_ACCEPT
DOM_VK_ADD
DOM_VK_AGAIN
DOM_VK_ALL_CANDIDATES Constant for the All Candidates function key.
DOM_VK_ALPHANUMERIC Constant for the Alphanumeric function key.
DOM_VK_ALT
DOM_VK_ALT_GRAPH Constant for the AltGraph modifier key.
DOM_VK_AMPERSAND
DOM_VK_ASTERISK
DOM_VK_AT Constant for the "@" key.
DOM_VK_B
DOM_VK_BACK_QUOTE
DOM_VK_BACK_SLASH
DOM_VK_BACK_SPACE
DOM_VK_BRACELEFT
DOM_VK_BRACERIGHT
DOM_VK_C
DOM_VK_CANCEL
DOM_VK_CAPS_LOCK
DOM_VK_CIRCUMFLEX Constant for the "^" key.
DOM_VK_CLEAR
DOM_VK_CLOSE_BRACKET
DOM_VK_CODE_INPUT Constant for the Code Input function key.
DOM_VK_COLON Constant for the ":" key.
DOM_VK_COMMA
DOM_VK_COMPOSE Constant for the Compose function key.
DOM_VK_CONTROL
DOM_VK_CONVERT
DOM_VK_COPY
DOM_VK_CUT
DOM_VK_D
DOM_VK_DEAD_ABOVEDOT
DOM_VK_DEAD_ABOVERING
DOM_VK_DEAD_ACUTE
DOM_VK_DEAD_BREVE
DOM_VK_DEAD_CARON
DOM_VK_DEAD_CEDILLA
DOM_VK_DEAD_CIRCUMFLEX
DOM_VK_DEAD_DIAERESIS
DOM_VK_DEAD_DOUBLEACUTE
DOM_VK_DEAD_GRAVE
DOM_VK_DEAD_IOTA
DOM_VK_DEAD_MACRON
DOM_VK_DEAD_OGONEK
DOM_VK_DEAD_SEMIVOICED_SOUND
DOM_VK_DEAD_TILDE
DOM_VK_DEAD_VOICED_SOUND
DOM_VK_DECIMAL
DOM_VK_DELETE
DOM_VK_DIVIDE
DOM_VK_DOLLAR Constant for the "$" key.
DOM_VK_DOWN
DOM_VK_E
DOM_VK_END
DOM_VK_ENTER
DOM_VK_EQUALS
DOM_VK_ESCAPE
DOM_VK_EURO_SIGN Constant for the Euro currency sign key.
DOM_VK_EXCLAMATION_MARK Constant for the "!" key.
DOM_VK_F
DOM_VK_F1 Constant for the F1 function key.
DOM_VK_F10 Constant for the F10 function key.
DOM_VK_F11 Constant for the F11 function key.
DOM_VK_F12 Constant for the F12 function key.
DOM_VK_F13 Constant for the F13 function key.
DOM_VK_F14 Constant for the F14 function key.
DOM_VK_F15 Constant for the F15 function key.
DOM_VK_F16 Constant for the F16 function key.
DOM_VK_F17 Constant for the F17 function key.
DOM_VK_F18 Constant for the F18 function key.
DOM_VK_F19 Constant for the F19 function key.
DOM_VK_F2 Constant for the F2 function key.
DOM_VK_F20 Constant for the F20 function key.
DOM_VK_F21 Constant for the F21 function key.
DOM_VK_F22 Constant for the F22 function key.
DOM_VK_F23 Constant for the F23 function key.
DOM_VK_F24 Constant for the F24 function key.
DOM_VK_F3 Constant for the F3 function key.
DOM_VK_F4 Constant for the F4 function key.
DOM_VK_F5 Constant for the F5 function key.
DOM_VK_F6 Constant for the F6 function key.
DOM_VK_F7 Constant for the F7 function key.
DOM_VK_F8 Constant for the F8 function key.
DOM_VK_F9 Constant for the F9 function key.
DOM_VK_FINAL
DOM_VK_FIND
DOM_VK_FULL_WIDTH Constant for the Full-Width Characters function key.
DOM_VK_G
DOM_VK_GREATER
DOM_VK_H
DOM_VK_HALF_WIDTH Constant for the Half-Width Characters function key.
DOM_VK_HELP
DOM_VK_HIRAGANA Constant for the Hiragana function key.
DOM_VK_HOME
DOM_VK_I
DOM_VK_INSERT
DOM_VK_INVERTED_EXCLAMATION_MARK Constant for the inverted exclamation mark key.
DOM_VK_J
DOM_VK_JAPANESE_HIRAGANA Constant for the Japanese-Hiragana function key.
DOM_VK_JAPANESE_KATAKANA Constant for the Japanese-Katakana function key.
DOM_VK_JAPANESE_ROMAN Constant for the Japanese-Roman function key.
DOM_VK_K
DOM_VK_KANA
DOM_VK_KANJI
DOM_VK_KATAKANA Constant for the Katakana function key.
DOM_VK_KP_DOWN for KeyPad cursor arrow keys
DOM_VK_KP_LEFT for KeyPad cursor arrow keys
DOM_VK_KP_RIGHT for KeyPad cursor arrow keys
DOM_VK_KP_UP for KeyPad cursor arrow keys
DOM_VK_L
DOM_VK_LEFT
DOM_VK_LEFT_PARENTHESIS Constant for the "(" key.
DOM_VK_LESS
DOM_VK_M
DOM_VK_META
DOM_VK_MINUS
DOM_VK_MODECHANGE
DOM_VK_MULTIPLY
DOM_VK_N
DOM_VK_NONCONVERT
DOM_VK_NUM_LOCK
DOM_VK_NUMBER_SIGN Constant for the "#" key.
DOM_VK_NUMPAD0
DOM_VK_NUMPAD1
DOM_VK_NUMPAD2
DOM_VK_NUMPAD3
DOM_VK_NUMPAD4
DOM_VK_NUMPAD5
DOM_VK_NUMPAD6
DOM_VK_NUMPAD7
DOM_VK_NUMPAD8
DOM_VK_NUMPAD9
DOM_VK_O
DOM_VK_OPEN_BRACKET
DOM_VK_P
DOM_VK_PAGE_DOWN
DOM_VK_PAGE_UP
DOM_VK_PASTE
DOM_VK_PAUSE
DOM_VK_PERIOD
DOM_VK_PLUS Constant for the "+" key.
DOM_VK_PREVIOUS_CANDIDATE Constant for the Previous Candidate function key.
DOM_VK_PRINTSCREEN
DOM_VK_PROPS
DOM_VK_Q
DOM_VK_QUOTE
DOM_VK_QUOTEDBL
DOM_VK_R
DOM_VK_RIGHT
DOM_VK_RIGHT_PARENTHESIS Constant for the ")" key.
DOM_VK_ROMAN_CHARACTERS Constant for the Roman Characters function key.
DOM_VK_S
DOM_VK_SCROLL_LOCK
DOM_VK_SEMICOLON
DOM_VK_SEPARATER
DOM_VK_SHIFT
DOM_VK_SLASH
DOM_VK_SPACE
DOM_VK_STOP
DOM_VK_SUBTRACT
DOM_VK_T
DOM_VK_TAB
DOM_VK_U
DOM_VK_UNDEFINED KEY_TYPED events do not have a keyCode value.
DOM_VK_UNDERSCORE Constant for the "_" key.
DOM_VK_UNDO
DOM_VK_UP
DOM_VK_V
DOM_VK_W
DOM_VK_X
DOM_VK_Y
DOM_VK_Z
Attributes
ctrlKey of type boolean, readonly
ctrlKey indicates whether the 'ctrl' key was depressed during the firing of the event.

shiftKey of type boolean, readonly
shiftKey indicates whether the 'shift' key was depressed during the firing of the event.

altKey of type boolean, readonly
altKey indicates whether the 'alt' key was depressed during the firing of the event. On some platforms this key may map to an alternative key name.

metaKey of type boolean, readonly
metaKey indicates whether the 'meta' key was depressed during the firing of the event. On some platforms this key may map to an alternative key name.

keyCode of type unsigned long, readonly
The value of keyCode holds the virtual key code value of the key which was depressed if the event is a key event. Otherwise, the value is zero.

charCode of type unsigned long, readonly
charCode holds the value of the Unicode character associated with the depressed key if the event is a key event. Otherwise, the value is zero.

Methods
initKeyEvent
Parameters

DOMString

typeArg

Specifies the event type.

boolean

canBubbleArg

Specifies whether or not the event can bubble.

boolean

cancelableArg

Specifies whether or not the event's default action can be prevent.

boolean

ctrlKeyArg

Specifies whether or not control key was depressed during the Event.

boolean

altKeyArg

Specifies whether or not alt key was depressed during the Event.

boolean

shiftKeyArg

Specifies whether or not shift key was depressed during the Event.

boolean

metaKeyArg

Specifies whether or not meta key was depressed during the Event.

unsigned long

keyCodeArg

Specifies the Event's keyCode

unsigned long

charCodeArg

Specifies the Event's charCode

views::AbstractView

viewArg

Specifies the Event's AbstractView.

No Return Value
No Exceptions

The different types of Key events that can occur are:

keypress
The keypress event occurs when a key is pressed. If the key remains depressed, multiple keypresses may be generated. This event maps not to the physical depression of the key but is instead the result of that action, often being the insertion of a character.
  • Bubbles: Yes
  • Cancelable: Yes
  • Context Info: keyCode, charCode
keydown
The keydown event occurs when a key is pressed down.
  • Bubbles: Yes
  • Cancelable: Yes
  • Context Info: keyCode, charCode
keyup
The keyup event occurs when a key is released.
  • Bubbles: Yes
  • Cancelable: Yes
  • Context Info: keyCode, charCode

6.6.4. Mutation event types

The mutation event set is designed to allow notification of any changes to the structure of a document, including attr and text modifications. It may be noted that none of the mutation events listed are designated as cancelable. This stems from the fact that it is very difficult to make use of existing DOM interfaces which cause document modifications if any change to the document might or might not take place due to cancelation of the related event. Although this is still a desired capability, it was decided that it would be better left until the addition of transactions into the DOM.

A DOM consumer can use the hasFeature of the DOMImplementation interface to determine whether the mutation event set has been implemented by a DOM implementation. The feature string for this event set is "MutationEvents".

Interface MutationEvent (introduced in DOM Level 2)

The MutationEvent interface provides specific contextual information associated with Mutation events.


IDL Definition
// Introduced in DOM Level 2:
interface MutationEvent : Event {
  readonly attribute Node             relatedNode;
  readonly attribute DOMString        prevValue;
  readonly attribute DOMString        newValue;
  readonly attribute DOMString        attrName;
  void               initMutationEvent(in DOMString typeArg, 
                                       in boolean canBubbleArg, 
                                       in boolean cancelableArg, 
                                       in Node relatedNodeArg, 
                                       in DOMString prevValueArg, 
                                       in DOMString newValueArg, 
                                       in DOMString attrNameArg);
};

Attributes
relatedNode of type Node, readonly
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, the relatedNode is the changed parent. If an event is instead dispatch to a subtree indicating a node was changed within it, the relatedNode is the changed node.

prevValue of type DOMString, readonly
prevValue indicates the previous value of text nodes and attributes in attrModified and charDataModified events.

newValue of type DOMString, readonly
newValue indicates the new value of text nodes and attributes in attrModified and charDataModified events.

attrName of type DOMString, readonly
attrName indicates the changed attr in the attrModified event.

Methods
initMutationEvent
Parameters

DOMString

typeArg

Specifies the event type.

boolean

canBubbleArg

Specifies whether or not the event can bubble.

boolean

cancelableArg

Specifies whether or not the event's default action can be prevent.

Node

relatedNodeArg

Specifies the Event's related Node

DOMString

prevValueArg

Specifies the Event's prevValue property

DOMString

newValueArg

Specifies the Event's newValue property

DOMString

attrNameArg

Specifies the Event's attrName property

No Return Value
No Exceptions

The different types of Mutation events that can occur are:

DOMSubtreeModified
This is a general event for notification of all changes to the document. It can be used instead of the more specific events listed below. Also, the requirement for some sort of batching of mutation events may be accomplished through this event. The target of this event is the lowest common parent of the changes which have taken place. This event is dispatched after any other events caused by the mutation have fired.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: None
DOMNodeInserted
Fired when a node has been added as a child of another node. This event is dispatched after the insertion has taken place. The target of this event is the node being inserted.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: relatedNode holds the parent node
DOMNodeRemoved
Fired when a node is being removed from another node. This event is dispatched before the node is removed from the tree. The target of this event is the node being removed.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: relatedNode holds the parent node
DOMNodeRemovedFromDocument
Fired when a node is being removed from a document, either through direct removal of the Node or removal of a subtree in which it is contained. This event is dispatched before the removal takes place. The target of this event is the node being removed. If the Node is being directly removed the nodeRemoved event will fire before the nodeRemovedFromDocument event.
  • Bubbles: No
  • Cancelable: No
  • Context Info: None
DOMNodeInsertedIntoDocument
Fired when a node is being inserted into a document, either through direct insertion of the Node or insertion of a subtree in which it is contained. This event is dispatched after the insertion has taken place. The target of this event is the node being inserted. If the Node is being directly inserted the nodeInserted event will fire before the nodeInsertedIntoDocument event.
  • Bubbles: No
  • Cancelable: No
  • Context Info: None
DOMAttrModified
Fired after an Attr has been modified on a node. The target of this event is the node whose Attr changed.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: attrName, prevValue, newValue
DOMCharacterDataModified
Fired after CharacterData within a node has been modified but the node itself has not been inserted or deleted. The target of this event is the CharacterData node.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: prevValue, newValue

6.6.5. HTML event types

The HTML event set is composed of events listed in HTML 4.0 and additional events which are supported in DOM Level 0 browsers.

A DOM consumer can use the hasFeature of the DOMImplementation interface to determine whether the HTML event set has been implemented by a DOM implementation. The feature string for this event set is "HTMLEvents".

The HTML events use the base DOM Event interface to pass contextual information.

The different types of such events that can occur are:

load
The load event occurs when the DOM implementation finishes loading all content within a document, all frames within a FRAMESET, or an OBJECT element.
  • Bubbles: No
  • Cancelable: No
  • Context Info: None
unload
The unload event occurs when the DOM implementation removes a document from a window or frame. This event is valid for BODY and FRAMESET elements.
  • Bubbles: No
  • Cancelable: No
  • Context Info: None
abort
The abort event occurs when page loading is stopped before an image has been allowed to completely load. This event applies to OBJECT elements.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: None
error
The error event occurs when an image does not load properly or when an error occurs during script execution. This event is valid for OBJECT elements, BODY elements, and FRAMESET element.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: None
select
The select event occurs when a user selects some text in a text field. This event is valid for INPUT and TEXTAREA elements.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: None
change
The change event occurs when a control loses the input focus and its value has been modified since gaining focus. This event is valid for INPUT, SELECT, and TEXTAREA. element.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: None
submit
The submit event occurs when a form is submitted. This event only applies to the FORM element.
  • Bubbles: Yes
  • Cancelable: Yes
  • Context Info: None
reset
The reset event occurs when a form is reset. This event only applies to the FORM element.
  • Bubbles: Yes
  • Cancelable: No
  • Context Info: None
focus
The focus event occurs when an element receives focus either via a pointing device or by tabbing navigation. This event is valid for the following elements: LABEL, INPUT, SELECT, TEXTAREA, and BUTTON.
  • Bubbles: No
  • Cancelable: No
  • Context Info: None
blur
The blur event occurs when an element loses focus either by the pointing device or by tabbing navigation. This event is valid for the following elements: LABEL, INPUT, SELECT, TEXTAREA, and BUTTON.
  • Bubbles: No
  • Cancelable: No
  • Context Info: None

previous   next   contents   objects   index