About This Product
FontsMadeEasy.com
 
Search This Database:
| Over 5000 Free Fonts | Tutorials | Javascript Forum | Other Javascript Resources | Cheat Sheet
Tutorial archive
General Questions
Javascript 1.2
Navigation
Numbers
Strings
Object Model
Reference Manual
Dialog
Windows
Frames
Forms
Images
Mouse Events
Colors
File Access
Control Status Bar
Dates and Time
Cookies
Client Information
Bookmarklets







[Contents] [Previous] [Next] [Last]


Chapter 2

Events

This section describes new and revised events.

All information about an event, such as its type, is now passed to its handler through the event object. The properties passed with the event object are listed under the heading "Event properties used." Pre-Navigator 4.0 events that aren't listed here use the type and target property only.

In Navigator 4.0, a window or document can capture events before they reach their intended target. For more information see "Event Capturing".

NOTE: Navigator 4.0 recognizes mixed-case and lower case use of events and event handlers. For example, you can explicitly call an event handler using either element.onclick or element.onClick.

Click

(Revised to include new properties) Occurs when the user clicks a link or a form element (a Click is a combination of the MouseDown and MouseUp events).

If the event handler returns false, the default action of the object is canceled as follows:

Syntax

onClick="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

document, Button, Checkbox, Link, Radio, Reset, and Submit objects

Event properties used

type indicates a Click event.

target indicates the object to which the event was originally sent.

When a link is clicked, layerX, layerY, pageX, pageY, screenX, and screenY represent the cursor location at the time the Click event occurred.

When a button is clicked, layerX, layerY, pageX, pageY, screenX, and screenY are unused.

which represents 1 for a left-mouse click and 3 for a right-mouse click.

modifiers contains the list of modifier keys held down when the Click event occurred.

DblClick

Occurs when the user double-clicks a form element or a link.

NOTE: DblClick is not implemented on the Macintosh.

Syntax

onDblClick="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

document, area, link object

Event properties used

type indicates a DblClick event.

target indicates the object to which the event was originally sent.

layerX, layerY, pageX, pageY, screenX, and screenY represent the cursor location at the time the DblClick event occurred.

which represents 1 for a left-mouse double-click and 3 for a right-mouse double-click.

modifiers contains the list of modifier keys held down when the DblClick event occurred.

DragDrop

Occurs when the user drops an object onto the Navigator window, such as dropping a file on the Navigator window.

Syntax

onDragDrop="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

window object

Event properties used

type indicates a DragDrop event.

target indicates the object to which the event was originally sent.

data returns an array of strings containing the URLs of the dropped objects.

Description

The DragDrop event is fired whenever a system item (file, shortcut, etc.) is dropped onto the Navigator window via the native system's drag and drop mechanism. The normal response for the Navigator is to attempt to load the item into the browser window. If the event handler for the DragDrop event returns true, the browser will load the item normally. If the event handler returns false, the drag and drop is canceled.

KeyDown

Occurs when the user depresses a key.

Syntax

onKeyDown="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

document, Image, Link, and Textarea objects

Event properties used

type indicates a KeyDown event.

target indicates the object to which the event was originally sent.

layerX, layerY, pageX, pageY, screenX, and screenY represent the cursor location at the time the KeyDown event occurred.

which represents the ASCII value of the key pressed. To get the actual letter, number, or symbol of the pressed key, use the fromCharCode method. To set this property when the ASCII value is unknown, use the charCodeAt method.

modifiers contains the list of modifier keys held down when the KeyDown event occurred.

Description

A KeyDown event always occurs before a KeyPress event. If onKeyDown returns false, no KeyPress events occur. This prevents KeyPress events occurring due to the user holding down a key.

See also

KeyPress and KeyUp events

KeyPress

Client-side event. Occurs when the user presses or holds down a key.

Syntax

onKeyPress="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

document, Image, Link, and Textarea objects

Event properties used

type indicates a KeyPress event.

target indicates the object to which the event was originally sent.

layerX, layerY, pageX, pageY, screenX, and screenY represent the cursor location at the time the KeyPress event occurred.

which represents the ASCII value of the key pressed. To get the actual letter, number, or symbol of the pressed key, use the fromCharCode method. To set this property when the ASCII value is unknown, use the charCodeAt method.

modifiers contains the list of modifier keys held down when the KeyPress event occurred.

Description

A KeyPress event occurs immediately after a KeyDown event only if onKeyDown returns something other than false. A KeyPress event repeatedly occurs until the user releases the key. You can cancel individual KeyPress events.

See also

KeyDown and KeyUp events

KeyUp

Event. Occurs when the user releases a key.

Syntax

onKeyUp="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

document, Image, Link, and Textarea objects

Event properties used

type indicates a KeyUp event.

target indicates the object to which the event was originally sent.

layerX, layerY, pageX, pageY, screenX, and screenY represent the cursor location at the time the KeyUp event occurred.

which represents the ASCII value of the key pressed. To get the actual letter, number, or symbol of the pressed key, use the fromCharCode method. To set this property when the ASCII value is unknown, use the charCodeAt method.

modifiers contains the list of modifier keys held down when the KeyUp event occurred.

MouseDown

Occurs when the user depresses a mouse button.

Syntax

onMouseDown="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

Button, document, and Link objects

Event properties used

type indicates a MouseDown event.

target indicates the object to which the event was originally sent.

layerX, layerY, pageX, pageY, screenX, and screenY represent the cursor location at the time the MouseDown event occurred.

which represents 1 for a left-mouse-button down and 3 for a right-mouse-button down.

modifiers contains the list of modifier keys held down when the MouseDown event occurred.

Description

If onMouseDown returns false, the default action (entering drag mode, entering selection mode, or arming a link) is canceled.

NOTE: Arming is caused by a MouseDown over a link. When a link is armed it changes color to represent its new state.

MouseMove

Occurs when the user moves the cursor.

Syntax

onMouseMove="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

None

Event properties used

type indicates a MouseMove event.

target indicates the object to which the event was originally sent.

layerX, layerY, pageX, pageY, screenX, and screenY represent the cursor location at the time the MouseMove event occurred.

Description

The MouseMove event is sent only when a capture of the event is requested by an object (see "Event Capturing").

See Also

captureEvents method

MouseOut

(Revised to include new properties) Occurs when the user moves the cursor out of an object.

Syntax

onMouseOut="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

Area, Layer, and Link objects

Event properties used

type indicates a MouseOut event.

target indicates the object to which the event was originally sent.

layerX, layerY, pageX, pageY, screenX, and screenY represent the cursor location at the time the MouseOut event occurred.

MouseOver

(Revised to include new properties) Occurs when the user moves the cursor over an object.

Syntax

onMouseOver="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

Area, Layer, and Link objects

Event properties used

type indicates a MouseOver event.

target indicates the object to which the event was originally sent.

layerX, layerY, pageX, pageY, screenX, and screenY represent the cursor location at the time the MouseOver event occurred.

MouseUp

Occurs when the user releases a mouse button.

Syntax

onMouseUp="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

Button, document, and Link objects

Event properties used

type indicates a MouseUp event.

target indicates the object to which the event was originally sent.

layerX, layerY, pageX, pageY, screenX, and screenY represent the cursor location at the time the MouseUp event occurred.

which represents 1 for a left-mouse-button up and 3 for a right-mouse-button up.

modifiers contains the list of modifier keys held down when the MouseUp event occurred.

Description

If onMouseUp returns false, the default action is canceled. For example, if onMouseUp returns false over an armed link, the link is not triggered. Also, if MouseUp occurs over an unarmed link (possibly due to onMouseDown returning false), the link is not triggered.

NOTE: Arming is caused by a MouseDown over a link. When a link is armed it changes color to represent its new state.

Move

Occurs when the user or script moves a window.

Syntax

onMove="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

window object

Event properties used

type indicates a Move event.

target indicates the object to which the event was originally sent.

screenX and screenY represent the position of the top-left corner of the window.

Resize

Occurs when a user or script resizes a window.

Syntax

onResize="handlerText"

Parameters

handlerText is JavaScript code or a call to a JavaScript function.

Event of

window objects

Event properties used

type indicates a Resize event.

target indicates the object to which the event was originally sent.

width and height represent the width and height of the window.

Description

This event is sent after HTML layout completes within the new window inner dimensions. This allows positioned elements and named anchors to have their final sizes and locations queried, image SRC properties can be restored dynamically, and so on.


[Contents] [Previous] [Next] [Last]