Quackit Logo
HTML
CSS
Scripting
Database
Hosting
Design
XML
Website builder

JavaScript Event Handlers

When your users visit your website, they do things like click on things, hover over things etc. These are examples of what JavaScript calls events. Using JavaScript, you can respond to an event using Event Handlers. You can attach an event handler to the HTML element for which you want to respond to when a specific event occurs. For example, you could attach JavaScript's onMouseover event handler to a button and specify some JavaScript to run whenever this event occurs against that button.

The HTML 4 specification defines 18 event handlers as listed below:

Event Handler Event that it handles
onBlur User has left the focus of the object. For example, they clicked away from a text field that was previously selected.
onChange User has changed the object, then attempts to leave that field (i.e. clicks elsewhere).
onClick User clicked on the object.
onDblClick User clicked twice on the object.
onFocus User brought the focus to the object (i.e. clicked on it/tabbed to it)
onKeydown A key was pressed over an element.
onKeyup A key was released over an element.
onKeypress A key was pressed over an element then released.
onLoad The object has loaded.
onMousedown The cursor moved over the object and mouse/pointing device was pressed down.
onMouseup The mouse/pointing device was released after being pressed down.
onMouseover The cursor moved over the object (i.e. user hovers the mouse over the object).
onMousemove The cursor moved while hovering over an object.
onMouseout The cursor moved off the object
onReset User has reset a form.
onSelect User selected some or all of the contents of the object. For example, the user selected some text within a text field.
onSubmit User submitted a form.
onUnload User left the window (i.e. user closes the browser window).

 

Enjoy this page?

  1. Add this page to your Favorites
  2. Link to this page (copy/paste into your own website or blog):
  3. Link to Quackit using one of these banner ads.

Thanks for supporting Quackit!