Events Reference

Events Reference



onabort

Description

Fires when the user aborts the download of the image.

Remarks

An image can be aborted by clicking a link, clicking the Stop button, and so on. This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event

Applies To

IMG


onafterupdate

Description

Fires after the transfer of data from the element to the data provider (after a successful onbeforeupdate).

Remarks

This event only fires when the object is databound and an onbeforeupdate event has fired (the element's data has changed). This event cannot be canceled. This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.

Applies To

APPLET, BODY, BUTTON, CAPTION, DIV, EMBED, IMG, INPUT, MAP, MARQUEE, OBJECT, SELECT, TABLE, TD, TEXTAREA, TR

See Also

onbeforeupdate


onbeforeunload

Description

Fires prior to a page being unloaded.

Remarks

This event gives you a chance to request that the user not leave the page. By returning a string to this event, a dialog box is displayed that gives the user the option to stay on the page. The returned string is displayed in a predefined area to provide the user with the reason.

This event also fires when a document.open is done and when a frameset is created.

Applies To

FRAMESET, window

See Also

onunload


onbeforeupdate

Description

Fires before the transfer of data from the element to the data provider. Fires when an element loses focus or the page is attempting to unload when the value of the element has changed from the value that was in the element at the time it received the focus.

Remarks

This event can be canceled. This allows the programmer to fail the validation and leave the content of the field as well as the cursor intact. All subsequent events are not fired when this event is canceled. This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.

Applies To

APPLET, BODY, BUTTON, CAPTION, DIV, EMBED, HR, IMG, INPUT, MAP, OBJECT, SELECT, TABLE, TD, TEXTAREA, TR

See Also

onafterupdate


onblur

Description

Fires when an object, such as a button or check box, loses the input focus.

Remarks

This event is fired even when clicking another control or the background of the page, switching applications, or opening another window within the browser. This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event

Applies To

A, APPLET, AREA, BUTTON, DIV, EMBED, HR, IMG, INPUT, MARQUEE, OBJECT, SELECT, SPAN, TABLE, TD, TEXTAREA, TR, window


onbounce

Description

Fires when the behavior property of the MARQUEE element is set to "alternate" and the contents of the marquee reach a side.

Remarks

This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event.

Applies To

MARQUEE


onchange

Description

Fires when the contents of the object have changed.

Remarks

This event is fired when the contents are committed, not while the value is changing. For example, on a text box, this event is not fired while the user is typing, but rather when the user commits the change by pressing ENTER or leaving the text box focus. This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event.

This code is executed before the code specified by onblur, if the control is also losing the focus.

Applies To

INPUT, SELECT, TEXTAREA

See Also

onkeypress


onclick

Description

Fires when the user presses and releases the left mouse button, or when the user presses keys, such as ENTER and ESC, in a form.

The following actions cause an onclick event:

Remarks

The default action of an onclick event depends on the object that receives the click. For example, clicking an A element causes the browser to load the document specified by the href property. You can cancel the default behavior by setting the returnValue property of the event object to FALSE.

If the user clicks the left mouse button, the onclick event for an object occurs only if the mouse pointer is over the object and both an onmousedown and an onmouseup event occur in order. For example, if the user presses down in the object but moves the mouse pointer out of the object before releasing, no onclick event occurs.

If the user clicks an object that can receive the input focus but does not already have the focus, the onfocus event occurs for that object before the onclick event. If the user double-clicks the left mouse button in a control, an ondblclick event occurs immediately after the onclick event.

This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.

Examples

The following JScript example is an onclick event handler for the document. It uses the event object to display the tag name of the element in which the click occurred.

<SCRIPT FOR=document EVENT=onclick LANGUAGE="JScript">
alert("Clicked in " + window.event.srcElement.tagName);
</SCRIPT>

The following VBScript example is an onclick event handler for the document. It uses the event object to determine whether the click occurred in an A element, and then cancels the event (and prevents a jump) if the SHIFT key is down.

<SCRIPT LANGUAGE="VBScript">
Function document_onclick()
    If window.event.srcElement.tagName = "A" And window.event.shiftKey Then
        window.event.returnValue = False
    End If
End Function
</SCRIPT>

Applies To

A, ADDRESS, APPLET, AREA, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET FONT, H1, H2, H3, H4, H5, H6, HR, I, IMG, INPUT, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP, FORM, document

See Also

click


ondataavailable

Description

Fires periodically as data arrives for data source objects that transmit their data asynchronously. Frequency of firing is dependent upon the data source object.

Remarks

This event fires for objects and applications that are data source objects. There is a qualifier property on the event object; the qualifier will always be set to "" for Internet Explorer 4.0. This event cannot be canceled. This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.

Applies To

APPLET, IMG, MAP, OBJECT


ondatasetchanged

Description

Fires when the data set exposed by a data source object changes—for example, when a filter operation takes place. Also fires when initial data is available from a data source object.

Remarks

This event fires for objects and applications that are data source objects. There is a qualifier property on the event object; the qualifier will always be set to "" for Internet Explorer 4.0. This event cannot be canceled. This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.

Applies To

APPLET, IMG, MAP, OBJECT


ondatasetcomplete

Description

Fires to indicate that all data is available from the data source object.

Remarks

This event fires for objects and applications that are data source objects. There is a qualifier property and a reason property on the event object. The qualifier will always be set to "" for Internet Explorer 4.0. This event cannot be canceled. This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.

The reason property is set to indicate the reason for completion and is one of these values:
0 Data transmitted successfully.
1 Data transfer aborted.
2 Data transfer in error.

Applies To

APPLET, IMG, MAP, OBJECT


ondblclick

Description

Fires when the user clicks twice over an object.

Return Value

Returns TRUE or FALSE. Returning FALSE cancels the default action.

Remarks

The ondblclick event occurs when the user clicks twice (presses and releases the left mouse button and then presses and releases it again) over an object. The two clicks must occur within the time limit specified by the system's double-click speed setting. This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.

The order of events leading to the ondblclick event is:

  1. onmousedown
  2. onmouseup
  3. onclick
  4. onmouseup
  5. ondblclick

Applies To

A, ADDRESS, APPLET, AREA, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, INPUT, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, OBJECT, OL, P, PLAINTEXT, PRE, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP, document


ondragstart

Description

Fires when the user first starts to drag a selection or selected element.

Remarks

For the INPUT element, the only types supported for this event are file, image, password, and text.

This event can be canceled. This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.

Applies To

A, ACRONYM, ADDRESS, AREA, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, DD, DEL, DFN, DIR, DIV, DL, DT, EM, FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, INPUT, KBD, LABEL, LI, LISTING, MAP, MARQUEE, MENU, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP, document


onerror

Description

Fires when a scripting error occurs; for example, when there are security problems during the loading process or just bad coding.

Remarks

When programming in VBScript, you can create an event handler that receives event parameters by defining a subroutine having this form:

Sub window_onerror(message, url, line)

The line parameter is an integer specifying the line number at which the error occurred, url is a string specifying the URL of the document containing the error, and the optional message is a message string. The following example uses JScript.

function errortrap(msg,url,line){
    alert(msg);
    return true;
}
onerror=errortrap;

This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event.

Applies To

window

See Also

onerror event for other objects


onerror

Description

Fires when an error occurs loading the image or other object.

Remarks

You can suppress error messages that occur when an image fails to load by setting the onerror attribute in the element to "null". This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event.

Applies To

IMG, LINK, OBJECT, SCRIPT, STYLE


onerrorupdate

Description

Fires when the onbeforeupdate event handler specified for the element has canceled the data transfer and is fired instead of the onafterupdate event.

Remarks

This event only fires when an onbeforeupdate event has fired (the element's data has changed). This event cannot be canceled. This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.

Applies To

A, APPLET, MAP, OBJECT, SELECT, TEXTAREA


onfilterchange

Description

Fires when a visual filter changes state or completes a transition.

Remarks

This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.

An asterisk in the following applies to list indicates that a defined height, width, or absolute position is required.

Applies To

BODY, BUTTON, DIV*, IMG, INPUT, MARQUEE, SPAN*, TABLE, TD, TEXTAREA, TFOOT, TH, THEAD, TR


onfinish

Description

Fires when looping is complete.

Remarks

This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event.

Applies To

MARQUEE


onfocus

Description

Fires when a control receives the focus. This event also fires for some noncontrol elements such as HR.

Remarks

This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event.

Applies To

A, APPLET, AREA, BUTTON, DIV, EMBED, HR, IMG, INPUT, MARQUEE, OBJECT, SELECT, SPAN, TABLE, TD, TEXTAREA, TR, window

See Also

focus


onhelp

Description

Fires when the user presses the F1 or Help key on the browser.

Remarks

This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event.

Applies To

A, ADDRESS, APPLET, AREA, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, INPUT, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP, document, window


onkeydown

Description

Fires when the user presses a key.

Return Value

Returns a number specifying the keycode of the key that was pressed.

Remarks

The return value can be used to override the keycode value. This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.

Applies To

A, ACRONYM, ADDRESS, APPLET, AREA, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, DD, DEL, DFN, DIR, DIV, DT, EM, FIELDSET, FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, INPUT, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, OBJECT, OL, P, PLAINTEXT, PRE, Q, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP, document

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.