20.9. Event Handling
One of the more powerful and often used techniques concerning JavaScript is events. Using event attributes in XHTML tags, such as onmouseover and onclick, you can create interactive documents that respond to the user's actions.
The following table lists the various events supported by JavaScript.
Event | Trigger |
---|---|
onAbort | Abort selected in browser (stop loading of image or document), usually by clicking the Stop button |
onBlur | When the object loses focus |
onChange | When the object is changed (generally a form element) |
onClick | When the object is clicked |
onDblClick | When the object is double-clicked |
onDragDrop | When an object is dropped into the user agent window (generally a file) |
onError | When a JavaScript error occurs (not a browser error — only JavaScript code errors will trigger this event) |
onFocus | When an object receives focus |
onKeyDown | When the user presses a key |
onKeyPress | When the user presses and/or holds down a key |
onKeyUp | When the user releases a key |
onload | When the object is loaded into the user agent (typically used with the <body> element to run a script when the document has completed loading) |
onMouseDown | When the mouse button is depressed |
onMouseMove | When the mouse is moved |
onMouseOut | When the mouse pointer moves outside the boundary of an object |
onMouseOver | When the mouse pointer moves within the boundary of an object |
onMouseUp | When the mouse button is released |
onMove | When an object (generally a window or frame) is moved |
onReset | When the user selects a reset button |
onResize | When an object (generally ... |
Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.