Javascript Events

An event is an unexpected external occurrence. Most JavaScript-applications perform actions as a response to events. An event is a signal from the browser that something has happened. Javascript provides events and event handlers to handle user interactions. These events and event handlers are as follows:

Abort:

Uses the event handler onAbort to handle aborting of an image loaded by the user.

Javascript Abort Event Example

Blur:

Uses onBlur handler to handle the event when an element, window or fram looses input focus.

Javascript Blur Event Example

Change:

Uses onChange handler to handle change in the value of a text field or area.

Javascript Change Event Example

Click:

Uses onClick handler when an object in a form is clicked.

Javascript Click Event Example

DblClick:

Uses a ondblClick handler to handle double clicking of a form object or link by the user.

Javascript DblClick Event Example

Error:

onError handler is used when there is an error in loading a document or an image.

Javascript Error Event Example

Focus:

Uses an onFocus handler to handle events like receiving of events by a window or frame.

Javascript Focus Event Example

Load:

Uses an onLoad handle to handle the event when the browser finishes loading a browser window.

Javascript Load Event Example

MouseOver:

Uses an onMouseOver handler when the curser move over an area.

Javascript MouseOver Event Example

MouseOut:

Uses an onMouseOut handler when the curser out from an area.

Javascript MouseOut Event Example

MouseOut:

Uses an onMouseOut handler when the curser out from an area.

Javascript MouseOver Event Example

Reset:

Uses an onReset handler to handle the event when a form is reset.

Javascript Reset Event Example

Submit:

Uses onSubmit handler to handle the event when the user submit the form.

Javascript Submit Event Example

Unload:

Uses onUnload handler to handle the event when the user exits a document.

Javascript Unload Event Example

KeyDown:

Uses onKeyDown to handle the event of user depressing a key.

Javascript KeyDown Event Example

KeyPress:

Uses onKeyPress handler to process key presses.

Javascript KeyPress Event Example

KeyUp:

Uses onKeyUp handler to process events like user releasing a key.

Javascript KeyUp Event Example

MouseDown:

Uses onMouseDown handler when the user presses mouse button.

Javascript MouseDown Event Example

MouseUp:

Uses onMouseUp handler when the user releases a mouse button.

Javascript MouseUp Event Example

HTML 4 Standard Events

The standard HTML 4 events are listed here for your reference. Here script indicates a Javascript function to be executed agains that event.

Event Value Description
onchange script Script runs when the element changes
onsubmit script Script runs when the form is submitted
onreset script Script runs when the form is reset
onselect script Script runs when the element is selected
onblur script Script runs when the element loses focus
onfocus script Script runs when the element gets focus
onkeydown script Script runs when key is pressed
onkeypress script Script runs when key is pressed and released
onkeyup script Script runs when key is released
onclick script Script runs when a mouse click
ondblclick script Script runs when a mouse double-click
onmousedown script Script runs when mouse button is pressed
onmousemove script Script runs when mouse pointer moves
onmouseout script Script runs when mouse pointer moves out of an element
onmouseover script Script runs when mouse pointer moves over an element
onmouseup script Script runs when mouse button is released