Event names (Definition)

Rules for naming event handlers.

When you specify the name of an event as an HTML tag attribute, because tag attributes in HTML are case insensitive, you only have to spell the event name correctly. You can type it in any mixture of upper and lower case and the browser should still be able to associate it with the correct fragment of JavaScript. These are all equally valid:

It is conventional to do it like this:

Inside the JavaScript interpreter, you can associate handlers using properties. However the event names must be correctly cased in that situation; they would be lower case. You don't need to put the onChange tag attribute in, because you are registering the error handler inside the script block, like this:

   <HTML>

   <BODY>

   <FORM NAME="the_form">

   <INPUT TYPE="text" NAME="the_text">

   </FORM>

   <SCRIPT>

   document.the_form.the_text.onchange=alert("Changed");

   </SCRIPT>

   </BODY>

   </HTML>

Here is a list of all event names although they don't all apply to every object in the document.

EventHandlerUsage
AbortonabortWhen image loading is aborted.
AfterPrintonafterprintWhen printing has just finished.
AfterUpdateonafterupdateWhen an update is completed.
BackonbackThe user has clicked on the [BACK] button in the toolbar.
BeforeCopyonbeforecopyImmediately before a copy to the clipboard.
BeforeCutonbeforecutImmediately before a cut to the clipboard.
BeforeEditFocusonbeforeeditfocusImmediately before the edit focus is directed to an element.
BeforePasteonbeforepasteImmediately before the clipboard is pasted.
BeforePrintonbeforeprintImmediately before printing begins.
BeforeUnloadonbeforeunloadCalled immediately prior to the window being unloaded.
BeforeUpdateonbeforeupdateCalled immediately before an update commences.
BluronblurWhen an input element loses input focus.
BounceonbounceTriggered when a marquee element hits the edge of its element area.
ChangeonchangeWhen edit fields have new values entered or a popup has a new selection, this event's handler can check the new value.
ClickonclickWhen the user clicks the mouse button on the Element object that represents the object on screen.
ContextMenuoncontextmenuSpecial handling for contextual menus.
CopyoncopyWhen a copy operation happens.
CutoncutWhen a cut operation happens.
DataAvailableondataavailableSome data has arrived asynchronously from an applet or data source.
DataSetChangedondatasetchangedA data source has changed the content or some initial data is now ready for collection.
DataSetCompleteondatasetcompleteThere is no more data to be transmitted from the data source.
DblClickondblclickWhen the user double-clicks on an object.
DragondragWhen a drag operation happens.
DragDropondragdropSome data has been dropped onto a window.
DragEndondragendWhen a drag ends.
DragEnterondragenterWhen a dragged item enters the element.
DragLeaveondragleaveWhen a dragged item leaves the element.
DragOverondragoverWhile the dragged item is over the element.
DragStartondragstartThe user has commenced some data selection with a mouse drag.
DropondropWhen a dragged item is dropped.
ErroronerrorTriggered if an error occurs when loading an image.
ErrorUpdateonerrorupdateAn error has occurred in the transfer of some data from a data source.
FilterChangeonfilterchangeA filter has changed the state of an element or a transition has just been completed.
FinishonfinishA marquee object has finished looping.
FocusonfocusWhen the form element is selected for entry.
ForwardonforwardThe user has clicked on the [FORWARD] button in the toolba.r
HelponhelpThe user has pressed the [F1] key or selected [help] from the toolbar or menu.
KeyDownonkeydownWhen a key is pressed.
KeyPressonkeypressPressing the key down and releasing it again elicits this event.
KeyUponkeyupWhen a key is released.
LoadonloadWhen an object has completed loading.
LoseCaptureonlosecaptureWhen an element loses event capturing permission.
MouseDownonmousedownWhen the mouse button is pressed.
MouseDragonmousedragAn event handler for mouse drag operations.
MouseMoveonmousemoveWhen the mouse pointer is moved.
MouseOutonmouseoutWhen the mouse pointer leaves the active area occupied by the Element object that represents the object on screen.
MouseOveronmouseoverWhen the mouse pointer enters the active area owned by the object.
MouseUponmouseupWhen the mouse button is released.
MoveonmoveThe browser window has been moved.
PasteonpasteWhen a paste operation happens.
PropertyChangeonpropertychangeWhen an object property is modified (similar to the Netscape Navigator watch() method).
ReadyStateChangeonreadystatechangeAn object in the window has changed its ready state.
ResetonresetThe user has clicked a reset button in a form.
ResizeonresizeAs the window is resized, this event is triggered.
RowEnteronrowenterThe data in a field bound to a data source is about to be changed.
RowExitonrowexitThe data in a field bound to a data source has been changed.
ScrollonscrollThe window has been scrolled.
SelectonselectSome textual content in the window has been selected.
SelectStartonselectstartA select action is beginning.
StartonstartA marquee element is beginning its loop.
StoponstopWhen a stop action occurs.
SubmitonsubmitThe user has clicked on the submit button in a form.
UnloadonunloadTriggered when the document is unloaded.

In the topics that describe the events, the intercap (capitalised word breaks) form is used so that the event name reads more easily.

Warnings:

See also:Event, Event handler, Event model, Keyboard events, Window.releaseEvents()