
Fires when a user presses a key.
Returns a number specifying the Unicode value of the key that was pressed.
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.
To cancel the keystroke, use the following code in the onkeypress event:
event.returnValue=false;
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
Fires when the user releases a key.
Returns a number specifying the keycode of the key released.
The return value can be used to override the keycode. This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.
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
Fires immediately after the browser loads the given object.
The browser loads applications, embedded objects, and images as soon as it encounters the APPLET, EMBED, and IMG elements during parsing. This means that the onload event for these objects occurs before the browser parses any subsequent elements. To ensure that an event handler receives the onload event for these elements, you must place the SCRIPT element that defines the event handler before the element and use the onload attribute in the element to set the handler.
The onload attribute of the BODY element sets an onload event handler for the window. Setting an onload event handler for the window object by any other means will override the handler set using the onload attribute if the handlers are in the same script language.
The following JScript example is an onload event handler for the window.
<SCRIPT FOR=window EVENT=onload LANGUAGE="JScript"> window.status = "Page is loaded!"; </SCRIPT>The following JScript example sets an onload event handler for an IMG element. The handler uses the event object to retrieve the URL of the image.
<SCRIPT LANGUAGE="JScript"> function imageLoaded() { window.status = "Image \"" + window.event.srcElement.src + "\" is loaded"; } </SCRIPT> <IMG SRC="sample.gif" onclick="imageLoaded()">This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event.
APPLET, BODY, EMBED, FRAMESET, IMG, LINK, SCRIPT, STYLE, window
Fires when the user presses a button on a pointer device, such as the mouse.
The event ordering for mouse-related events is:
- onmousedown
- onmouseup
- onclick
- ondblclick
- onmouseup
This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.
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
Fires when the user moves the mouse.
The event ordering for moving the mouse is:
- onmouseover
- onmousemove
- onmouseout
This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.
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
Fires when the user moves the mouse pointer out of an element.
When the user moves the mouse pointer into an element, one onmouseover event occurs, followed by one or more onmousemove events as the user moves the pointer within the element, and finally one onmouseout event when the user moves the pointer out of the element. This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.
The following JScript example sets the onmouseout event handler for an element having the identifier "para_1". The handler changes the color of the text in the element when the mouse pointer leaves the element.
<SCRIPT FOR=para_1 EVENT=onmouseout LANGUAGE="JScript"> var el = window.event.srcElement; for ( ; el.id != "para_1"; el = el.parentElement); el.style.color = "silver"; </SCRIPT>The following JScript example sets the onmouseout event handler for an IMG element. The handler changes the image source file for the element when the mouse pointer leaves the element.
<IMG SRC="inactive.gif" onmouseover="flipImage('active.gif')" onmouseout="flipImage('inactive.gif')"> . . . <SCRIPT LANGUAGE="JScript"> function flipImage(url) { if (window.event.srcElement.tagName == "IMG" ) { window.event.srcElement.src = url; } } </SCRIPT>
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
Fires when the user moves the mouse pointer into an element. The event occurs when the pointer first enters the element and does not repeat unless the user moves the pointer out of the element and then back into it.
When the user moves the mouse pointer into an element, one onmouseover event occurs, followed by one or more onmousemove events as the user moves the pointer within the element, and finally one onmouseout event when the user moves the pointer out of the element. This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.
The following JScript example sets the onmouseover event handler for an element having the identifier "para_1". The handler changes the color of the text in the element when the mouse pointer enters the element.
<SCRIPT FOR=para_1 EVENT=onmouseover LANGUAGE="JScript"> var el = window.event.srcElement; for ( ; el.id != "para_1"; el = el.parentElement); el.style.color = "black"; </SCRIPT>The following JScript example sets the onmouseover event handler for an IMG element. The handler changes the image source file for the element when the mouse pointer enters the element.
<IMG SRC="inactive.gif" onmouseover="flipImage('active.gif')" onmouseout="flipImage('inactive.gif')"> . . . <SCRIPT LANGUAGE="JScript"> function flipImage(url) { if (window.event.srcElement.tagName == "IMG" ) { window.event.srcElement.src = url; } } </SCRIPT>
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
Fires when the user releases a mouse button.
This event will bubble. Events that bubble can be handled on any parent element of the object that fired the event.
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
Fires whenever the ready state for the object has changed.
Each object can choose to expose which set of ready states it is exposing. This event should be fired whenever the ready state is changed.
When an element changes to the loaded state, this event fires immediately before the firing of the load event. This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event.
APPLET, EMBED, FRAME, FRAMESET, IFRAME, IMG, LINK, OBJECT, SCRIPT, STYLE, document
Fires when a user resets a form (clicks a Reset button). The onreset event handler executes code when a reset event occurs.
This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event.
Fires at the beginning of a resize operation.
This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event. This event will not fire for files with embedded controls.
APPLET, BUTTON, CAPTION, DIV, EMBED, FRAMESET, HR, IMG, MARQUEE, SELECT, TABLE, TD, TR, TEXTAREA, window
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.