Javascript Event Handlers

Guest Author - Elizabeth Connick

Event handlers are a vital tool for web developers, because they allow us to build a script that will run only if and when a specific event occurs. Introduced in HTML 4.0, they add a dynamic element to a website, allowing programs to run in response to your visitors' actions.

Event Handler

Trigger

onabort

Visitor cancels a loading image

onblur

An element loses focus (e.g. visitor clicks out of a form field)

onchange

Visitor changes the content of a field

onclick

Visitor clicks an object with the mouse cursor

ondblclick

Visitor double-clicks an object

onerror

An error occurs when loading a document or an image

onfocus

An element gets focus (e.g. visitor clicks on or tabs into a form field)