XML DOM Event Object

The Event object represents information about the event.

Event Object

The properties of the Event object provide details about the event (such as the element on which the event occurs). The methods of the Event object can control the propagation of the event.

The 2nd level DOM Events standard defines a standard event model that is implemented by all modern browsers except IE, while IE defines its own, incompatible model. This reference page lists the properties of the standard Event object as well as the properties of the IE Event object.

Note:In the standard event model, the Event object is passed to the event handler function; however, in the IE event model, it is stored in the event attribute of the Window object.

In the standard event model, various sub-interfaces of Event define additional properties that provide details related to specific event types. In the IE event model, there is only one type of Event object, which is used for all types of events.

Standard Event Properties

The following lists the properties defined by the 2nd level DOM event standard.

Properties Description IE F O W3C
bubbles Returns a boolean value indicating whether the event is a bubbling event type. No 1 9 Yes
cancelable Returns a boolean value indicating whether the event can cancel the default action. No 1 9 Yes
currentTarget Returns the element that triggered the event by its event listener. No 1 9 Yes
eventPhase Returns the current phase of the event propagation.       Yes
target Returns the element that triggered this event (the event's target node). No 1 9 Yes
timeStamp Returns the date and time the event was generated. No 1 9 Yes
type Returns the name of the event represented by the current Event object. 6 1 9 Yes

Standard Event Methods

The following lists the methods defined by the 2nd level DOM event standard. The IE event model does not support these methods:

Method Description IE F O W3C
initEvent() Initialize the properties of the newly created Event object. No 1 9 Yes
preventDefault() Notify the browser not to execute the default action associated with the event. No 1 9 Yes
stopPropagation() Stop the further propagation of the event during the capture, target handling, or bubbling phase of the event propagation process. After calling this method, the event handler on this node will be called, and the event will no longer be dispatched to other nodes. No 1 9 Yes

IE Properties

IE does not support the standard DOM event model (at least in IE 7), and the IE Event object defines a set of completely different properties.

The IE event model does not define an inheritance hierarchy for different event types, so all properties related to any event type are listed here.

Properties Description
cancelBubble If the event handler wants to prevent the event from propagating to the containing object, this property must be set to true.
fromElement For mouseover and mouseout events, fromElement refers to the element from which the mouse is moved.
keyCode

For keypress events, this property declares the Unicode character code generated by the key pressed.

For keydown and keyup events, it specifies the virtual keyboard code of the key pressed.

The virtual keyboard code may be related to the layout of the keyboard used.

offsetX,offsetY The x and y coordinates of the location where the event occurs in the coordinate system of the event source element.
returnValue

If this property is set, its value has a higher priority than the return value of the event handler.

Setting this property to false can cancel the default action of the event source element.

srcElement For the Window Object, Document Object, or Element Object that generates the event, this property is a reference.
toElement For mouseover and mouseout events, this property refers to the element over which the mouse is moved.
x,y The x and y coordinates of the location where the event occurs, which are relative to the innermost containing element dynamically positioned with CSS.