↑
Main Page
HTML events
Sequencing
When the user presses a character key once, the following sequence of events occurs:
1.
keydown
1.
keypress
2.
keyup
If the user presses a non-character key once, such as Shift, the following event sequence takes place:
1.
keydown
2.
keyup
If the user presses a character key and holds it down,
keydown
and
keypress
are fired repeatedly, one
after the other, until the key is released; if the user presses and holds down a non-character key, only the
keydown
event fires repeatedly. You can test this out using the previous example.
HTML events
The HTML events group makes up a large number of the remaining events from the original event
model created by developers of IE 4.0 and Netscape 4.0. It includes the following:
?
The
load
event, which fires on a
window
when the page has been completely loaded, on a
frameset when all frames have been completely loaded, on an
<img/>
element when it has been
completely loaded, or on an
<object />
element when it has been completely loaded.
?
The
unload
event, which fires on a
window
when the page has been completely unloaded, on a
frameset when all frames have been completely unloaded, or on an
<object/>
element when it
has been completely unloaded.
?
The
abort
event, which fires on an
<object/>
element if it is not fully loaded before the user
stops the download process.
?
The
error
event, which fires on a
window
when a JavaScript error occurs, on an
<img/>
ele-
ment if the image specified cannot be loaded, on an
<object/>
element if it cannot be loaded,
or on frameset if one or more frames cannot be loaded. This event is discussed in Chapter 14,
“Error Handling.”
?
The
select
event, which fires when the user selects one or more characters in a text box (either
<input/>
or
<textarea/>
). This event is discussed further in Chapter 11, “Forms and Data
Integrity.”
?
The
change
event, which fires on a text box (either
<input/>
or
<textarea/>
) when it loses
focus and the value has changed since the textbox got focus, and on a
<select/>
element when
its value is changed. This event is discussed further in Chapter 11.
?
The
submit
event, which fires on a
<form/>
when a Submit button (
<input type=”submit”/>
)
is clicked. This event is discussed further in Chapter 11.
?
The
reset
event, which fires on a
<form/>
when a Reset button (
<input type=”reset”/>
) is
clicked. This event is discussed further in Chapter 11.
286
Chapter 9
12_579088 ch09.qxd 3/28/05 11:39 AM Page 286
Free JavaScript Editor
Ajax Editor
©
→