eventNN 4   IE 4   DOM n/a

While the event object contains information about a user- or system-generated event in Navigator and Internet Explorer, the event mechanisms for the two browser families are very different, as described in . With only a few exceptions, the event object properties for the two browsers are mutually exclusive. Observe the browser compatibility listings for each of the following properties carefully.

 
 
Object Model Reference
NN eventObj
IE window.event
altKeyNN n/a   IE 4   DOM n/a
 Read-only
 

Reveals the state of the Alt key at the time the event fired.

 
Example
if (event.altKey) {
    handle case of Alt key down
}
 
Value
Boolean value: true | false.
 
Default false
buttonNN n/a   IE 4   DOM n/a
 Read-only
 

Which mouse button was pressed to trigger the mouse event. Although theoretically you should be able to detect the right button, Internet Explorer 4 does not fire mouse events with that button, since context menus always appear in the browser.

 
Example
if (event.button == 1) {
    handle event for left button
}
 
Value
Any of the following allowed integers: 0 (no button) | 1 (left button) | 2 (right button) | 4 (middle button of three-button mouse).
 
Default 0
cancelBubbleNN n/a   IE 4   DOM n/a
 Read/Write
 

Specifies whether the event should propagate (bubble) up the element container hierarchy. You usually only need to set this property to true to override the default behavior and prevent the event from going any further.

 
Example
window.event.cancelBubble = true
 
Value
Boolean: true | false.
 
Default false
clientX, clientYNN n/a   IE 4   DOM n/a
 Read-only
 

The horizontal (x) and vertical (y) coordinate of the mouse at the moment the current event fired. These coordinates are relative to the viewable document area of the browser window or frame.

 
Example
if ((event.clientX >= 10 || event.clientX <= 20) && 
(event.clientY >= 50 || event.clientY <= 100)) {
    process code for click in hot zone bounded by 10,50 and 20,100
}
 
Value
Integer of pixel values.
 
Default None.
ctrlKeyNN n/a   IE 4   DOM n/a
 Read-only
 

Whether the Control key was pressed at the instant the event fired. See for testing for this key in cross-browser event handling code.

 
Example
if (event.ctrlKey) {
    process for Control key being down
}
 
Value
Boolean value: true | false.
 
Default false
dataNN 4   IE n/a   DOM n/a
 Read-only
 

Accessory data associated with the event. As of Navigator 4, the only event for which the data property has information is the dragdrop event, in which case the data property returns the URL of the item being dropped onto the window or frame.

 
Example
var srcDoc = evtObj.data
 
Value
String.
 
Default None.
fromElementNN n/a   IE 4   DOM n/a
 Read-only
 

Returns a reference to the object where the cursor had been just prior to the onMouseOver or onMouseOut event.

 
Example
if (event.fromElement.id == "lowerLevel") {
    ...
}
 
Value
Object reference.
 
Default None.
keyCodeNN n/a   IE 4   DOM n/a
 Read/Write
 

The Unicode key value for the keyboard key that triggered the event. For onKeyPress events, the value represents the actual character displayed in a text box (e.g., 65 for "A" and 97 for "a"). But for onKeyDown and onKeyUp events, only the uppercase value is returned, regardless of the case of the character that is rendered. If the event is not keyboard driven, the value is zero. While you may change the value of this property, it does not influence the character displayed in the text field. See about capturing keyboard events.

 
Example
if (event.keyCode == 65) {
    ...
}
 
Value
Integer.
 
Default None.
layerX, layerYNN 4   IE n/a   DOM n/a
 Read-only
 

The horizontal (x) and vertical (y) coordinate of the mouse at the moment the current event fired. These coordinates are relative to the containing layer. If no layers or positionable elements have been defined, the default layer of the base document is used as a reference point, thus being equivalent to the pageX and pageY properties.

 
Example
if ((evtObj.layerX >= 10 || evtObj.layerX <= 20) && 
(evtObj.layerY >= 50 || evtObj.layerY <= 100)) {
    process code for click in hot zone bounded by 10,50 and 20,100
}
 
Value
Integer of pixel values.
 
Default None.
modifiersNN 4   IE n/a   DOM n/a
 Read-only
 

An integer that represents the keyboard modifier key(s) being held down at the time the event fired. You can use the & operator with a series of Event object constants to find out whether a particular modifier key was pressed. See .

 
Example
var altKeyPressed = evtObj.modifiers & Event.ALT_MASK
 
Value
Integer.
 
Default 0
offsetX, offsetYNN n/a   IE 4   DOM n/a
 Read-only
 

The left and top coordinates of the mouse pointer relative to the containing element (exclusive of padding, borders, or margins) when the event fired. You can determine the containing element via the offsetParent property. See the section "About client- and offset- Properties" at the beginning of this chapter about offset measurement anomalies in Internet Explorer 4.

 
Example
if (event.offsetX <= 20 && event.offsetY <=40) {
    ...
}
 
Value
Integer pixel count.
 
Default None.
pageX, pageYNN 4   IE n/a   DOM n/a
 Read-only
 

The left and top coordinates of the element's content relative to the top-left corner of the page area when the event fired. The measurements ignore any scrolling of the page.

 
Example
if (evtObj.pageX <= 20 && evtObj.pageY <=40) {
    ...
}
 
Value
Integer pixel count.
 
Default None.
reasonNN n/a   IE 4   DOM n/a
 Read-only
 

Returns a code associated with an onDataSetComplete event signifying whether the data transfer was successful or, if incomplete, whether the transfer stopped due to an error or a stoppage by the client or user. This property must be examined in an event handler for the onDataSetComplete event.

 
Example
if (event.reason == 2) {
    alert("An error occurred during the most recent update.")
}
 
Value
One of three possible integer values:
0 Transfer was successful
1 Transfer aborted
2 An error halted the transfer
 
Default None.
returnValueNN n/a   IE 4   DOM n/a
 Read/Write
 

The value to be returned to the event's source element to allow or prohibit the element's default action connected with the event. If you set event.returnValue to false, the element does not carry out its normal operation, such as navigating to a link or submitting the form.

 
Example
event.returnValue = "false"
 
Value
Boolean value: true | false.
 
Default true
screenX, screenYNN 4   IE 4   DOM n/a
 Read-only
 

Horizontal and vertical pixel coordinate points where the cursor was located on the video screen when the event occurred. The top-left corner of the screen is point 0,0. There is no particular coordination with the browser window, unless you have positioned the window and know where the active window area is in relation to the screen.

 
Example
// NN
if (evtObj.screenX < 5 || evtObj.screenY < 5) {
    alert("You\'re too close to the edge!")
}
// IE
if (event.screenX < 5 || event.screenY < 5) {
    alert("You\'re too close to the edge!")
}
 
Value
Any positive integer or zero.
 
Default None.
shiftKeyNN n/a   IE 4   DOM n/a
 Read-only
 

Reveals the state of the Shift key at the time the event fired.

 
Example
if (event.shiftKey) {
    handle case of Shift key down
}
 
Value
Boolean value: true | false.
 
Default false
srcElementNN n/a   IE 4   DOM n/a
 Read-only
 

Reference to the element object that fired the current event. This property is convenient in switch constructions for an event handler function that handles the same event type for a number of different elements.

 
Example
switch (event.srcElement.id) {
    case myDIV:
        ...
    ...
}
 
Value
Object reference.
 
Default None.
srcFilterNN n/a   IE 4   DOM n/a
 Read-only
 

Reference to the filter object that fired the current onFilterChange event. This property is convenient in switch constructions for an event handler function that handles the same event type for a number of different elements.

 
Example
switch (event.srcFilter.id) {
    case myDIV:
        ...
    ...
}
 
Value
Object reference.
 
Default None.
targetNN 4   IE n/a   DOM n/a
 Read-only
 

Reference to the element object that is the intended destination of the current event. This property is convenient in switch constructions for an event handler function that handles the same event type for a number of different elements.

 
Example
switch (evtObj.target.name) {
    case "myButton":
        ...
    ...
}
 
Value
Object reference.
 
Default None.
toElementNN n/a   IE 4   DOM n/a
 Read-only
 

Returns a reference to the object to which the cursor has moved that triggered the onMouseOut event.

 
Example
if (event.toElement.id == "upperLevel") {
    ...
}
 
Value
Object reference.
 
Default None.
typeNN 4   IE 4   DOM n/a
 Read-only
 

The type of the current event (without the "on" prefix). Values are all lowercase.

 
Example
// NN
if (evtObj.type ==  "change") {
    ...
}
// IE
if (event.type ==  "change") {
    ...
}
 
Value
Any event name (without the "on" prefix) as a string.
 
Default None.
whichNN 4   IE n/a   DOM n/a
 Read-only
 

Returns a value relevant to the type of event. For mouse events, the property value is an integer indicating which mouse button was used (1 is the left button; 3 is the right button). For keyboard events, the property value is an integer of the keyboard character ASCII code.

 
Example
if (evtObj.which == 65) {
    ...
}
 
Value
Integer.
 
Default None.
x, yNN n/a   IE 4   DOM n/a
 Read-only
 

Returns the horizontal and vertical pixel coordinates of the mouse pointer at the time the event occurred. The coordinate system is either a positioned element or the BODY element. A value of -1 is returned if the pointer was outside of the document area of the browser window.

 
Example
if (event.x < 20 && event.y < 30) {
    ...
}
 
Value
Integer.
 
Default None.