HTML Event Handlers

This is a brief listing of HTML Event Handlers which are used to trigger JavaScript code in web pages:

onAbort The loading of an image has been canceled
onBlur A page element loses focus
onChange The user changes the content of a form field
onClick The user uses the mouse to click on a page element
onDblClick The user uses the mouse to double-click on a page element
onError An error occurs when loading a page or an image
onFocus A page element gets focus (selected)
onKeyDown The user presses a keyboard key
onKeyPress The user presses or holds down a keyboard key
onKeyUp The user releases a previously pressed keyboard key
onLoad A page or an image finishes loading
onMouseDown The user presses a mouse button
onMouseMove The mouse cursor moves
onMouseOut The mouse cursor moves off of a page element
onMouseOver The mouse cursor moves over a page element
onMouseUp The user releases a previously pressed mouse button
onReset The form is reset; the reset button is clicked
onResize A window or frame is resized
onSelect The user selects some text on the page
onSubmit The form is submitted; the submit button is clicked or the enter key is pressed
onUnload The user leaves the current page

Note: Event Handlers that are device-non-specific are preferred to those that are device-specific. So, for example, use onFocus and onBlur instead of onMouseUp and onMouseDown since the latter are triggered specifically by using the mouse. Keyboard presses will not trigger such an event. Using onFocus and onBlur will make the event device neutral and will be triggered by both the keyboard and the mouse.

Remember, the above event handlers are actually part of XHTML (since HTML 4) not JavaScript. JavaScript now boasts an extended list of event handlers. See http://www.java2s.com/Code/JavaScript/Event-onMethod/CatalogEvent-onMethod.htm for details.

Advertisements

One response to “HTML Event Handlers

  1. Pingback: Advancing your Web Site: Tackling the Joys and Jitters of Javascript « DanielSmithDesigns Weblog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s