The names of some event handlers clearly describe what actions trigger the event. (It doesn’t take rocket science to figure that an onClick event is fired when something is clicked.) Other events are a little less intuitive.
Remember, also, that event names change in different environments. For example, the JavaScript onBlur event is called the LostFocus event in most Windows programming environments.
Table 8-2 shows JavaScript event handlers and the actions that fire them.
Event | Action That Fires the Event |
---|---|
onAbort | The loading of an image is interrupted. |
onBlur | The object loses input focus—typically because the user moves to another screen element using the mouse or keyboard. |
onChange | In a select list, the user selects or deselects an element. In a text box, the user enters or changes text and causes focus to move to another object. |
onClick | The user clicks once. You can return false in code to cancel a default action. |
onDblClick | The user clicks twice. |
onError | An error occurs while loading an image. |
onFocus | The object gains input focus—usually because the user has moved to the object using the mouse or keyboard. |
onKeyDown | The user presses a key. You can return false in code to cancel. |
onKeyPress | The user presses or releases a key. (onKeyPress is the same as onKeyDown or onKeyUp.) |
onKeyUp | The user releases a key. |
onLoad | A document or image finishes loading. |
onMouseDown | The user presses a mouse button. |
onMouseOut | The mouse is moved off an element. |
onMouseOver | The mouse is moved over an element. (For links, to prevent the URL from appearing in the status bar, return true.) |
onMouseUp | The user releases a mouse button. |
onReset | A form reset is requested. |
onResize | A window is resized. |
onSubmit | A form submission is requested. |
onUnload | A document is unloaded. |