You are here: Reference > JavaScript > client-side > event handling > events

Events in JavaScript

Character input and clipboard events:

Property Support Description
onbeforecopy
Occurs before the selection is copied to the clipboard and before the oncopy event.
onbeforecut
Occurs before the selection is cut from the document and provides a possibility to enable the Cut menu item.
onbeforepaste
Occurs before the contents of the clipboard are pasted into the document and provides a possibility to enable the Paste menu item.
oncopy
Occurs before the selection is copied to the clipboard.
oncut
Occurs before the selection is cut from the document and added to the clipboard.
oninput
9
Occurs when the text content of an element is changed through the user interface.
onkeydown
Occurs on an element that has the focus when a key is pressed down and occurs periodically until the key is released.
onkeypress
Occurs on an element that has the focus when a key is pressed down and occurs periodically until the key is released.
onkeyup
Occurs on an element that has the focus when the user releases a key.
onpaste
Occurs before the contents of the clipboard are pasted into the document.
textInput
9
Occurs when some characters are entered into an element.

Load, unload and state events:

Property Support Description
onabort
Occurs when the user aborts the loading of an img or input:image element.
onbeforeunload
Occurs before the browser unloads the document and provides a possibility to display a confirmation dialog, where the user can confirm whether he wants to stay or leave the current page.
onhashchange
83.610.65
Occurs when the hash subsection (begins with a '#' sign) of the current document's URL has changed.
onload
Occurs when an object has been loaded.
onoffline
83
Occurs when the browser starts to work offline.
ononline
83
Occurs when the browser starts to work online.
onreadystatechange
Occurs when the load state of the data that belongs to an element or a HTML document changes.
onreadystatechange (XMLDocument)
Occurs when the load state of the XMLDocument object changes.
onreadystatechange (XMLHttpRequest)
Occurs when the state of the request changes.
onstop
Occurs when the user aborts the loading of the document.
onunload
Occurs before the browser unloads the document.

Form events:

Property Support Description
onreset
Occurs on a form before it is reset.
onsubmit
Occurs on a form element when the user clicks on a submit button in the form.

Mouse events and scrolling:

Property Support Description
onclick
Occurs when the user clicks on an element.
oncontextmenu
10.5
Occurs when the right mouse button is clicked on an element and the context menu is shown.
ondblclick
Occurs when the user double clicks on an element.
onlosecapture
Occurs when the object loses the mouse capture.
onmouseenter
Occurs when the user moves the mouse pointer into the area of an element.
onmousedown
Occurs when the user presses a mouse button over an element.
onmouseleave
Occurs when the user moves the mouse pointer out of the element.
onmousemove
Occurs when the user moves the mouse over the element.
onmouseout
Occurs when the user moves the mouse pointer out of the element.
onmouseover
Occurs when the user moves the mouse pointer into the element.
onmouseup
Occurs when the user releases a mouse button over an element.
onmousewheel
Occurs when the mouse wheel rolls.
onscroll
Occurs when the contents of an element have been scrolled.

Move and drag events:

Property Support Description
onmove
Occurs when the position of an element's top-left corner is changed.
onmoveend
Occurs when the user stops dragging an absolute or relative positioned element in an editable region.
onmovestart
Occurs when the user starts dragging an absolute or relative positioned element in an editable region.
ondrag
3
Occurs periodically on the source element during the drag operation.
ondragend
3
Occurs on the source element when the user has finished the drag operation.
ondragenter
Occurs on an element when the user moves the mouse pointer into it during a drag operation.
ondragleave
3.5
Occurs on an element when the user moves the mouse pointer out of it during a drag operation.
ondragover
Occurs periodically on an element while the mouse pointer is over it during a drag operation.
ondragstart
3.5
Occurs on the source element when the user starts the drag operation.
ondrop
3.5
Occurs on a possible target element when the dragged data is dropped on it.

Resize events:

Property Support Description
onresize
Occurs when the size of an object has changed.
onresizeend
Occurs when the user stops resizing an element in an editable region.
onresizestart
Occurs when the user starts to resize an element in an editable region.

Activation and focus events:

Property Support Description
onactivate
Occurs when an element becomes active.
onbeforeactivate
Occurs before an element becomes active.
onbeforedeactivate
Occurs on the active element before it loses the active state.
onbeforeeditfocus
Occurs before an input:file, input:password, input:text or textarea element or an element in an editable region becomes a UI-activated.
onblur
Occurs when an element loses focus.
ondeactivate
Occurs on the active element when it loses the active state.
onfocus
Occurs when an element receives focus.
onfocusin
Occurs before an element receives focus.
onfocusout
Occurs after an element loses focus.

Selection events:

Property Support Description
oncontrolselect
Occurs before a control is selected in an editable region.
onselect
Occurs after some text has been selected in an element.
onselectionchange
Occurs when the selection in the document has changed.
onselectstart
Occurs at the start of a selection process.

Print and help events:

Property Support Description
onafterprint
Occurs when the browser has built the contents of the current document for printing or for the print preview.
onbeforeprint
Occurs when the browser starts to build the contents of the current document for printing or for the print preview.
onhelp
Occurs after the user has pressed the F1 key.

Error events:

Property Support Description
onerror
Fires when an error occurs while loading an external file.
onerror (window)
Fires when a script error occurs.
onerrorupdate
Occurs on a databound object when it cannot update the data in the data source object.

DataBound events:

Property Support Description
onafterupdate
Occurs on a databound object after it updates the data in the data source object.
onbeforeupdate
Occurs on a databound object before it updates the data in the data source object.
oncellchange
Occurs on a data source object when the data in it has changed.
ondataavailable
Occurs each time when a new chunk of data becomes available from the source.
ondatasetchanged
Occurs on a data source object when the initial or a new data set becomes available.
ondatasetcomplete
Occurs on a data source object when all its data becomes available.
onrowenter
Occurs on a data source object when the current row in it has changed.
onrowexit
Occurs on a data source object before the current row in it changes.
onrowsdelete
Occurs on a data source object before rows are deleted.
onrowsinserted
Occurs on a data source object when rows have been inserted.

Marquee events:

Property Support Description
onbounce
Occurs when the contents of a marquee element touch one side of the marquee element's bounding rectangle.
onfinish
Occurs when a marquee element has finished the scrolling animation.
onstart
Occurs when a marquee element begins the scrolling animation and when a new loop starts.

Change events:

Property Support Description
onchange
Occurs when the selection, the checked state or the contents of an element have changed. In some cases, it only occurs when the element loses the focus.
onfilterchange
Occurs after a filter has changed or finished a transition.
onpropertychange
Occurs every time when the value of an element's property is changed.

Search event:

Property Support Description
onsearch
Occurs when the user presses the ENTER key or clicks the 'Erase search text' button (x) in an input:search field.

Cross-document communication event:

Property Support Description
onmessage
83
Occurs when the postMessage method sends a message to the current window.

Additional events:

Property Support Description
CheckboxStateChange
Occurs when the state of a checkbox has changed.
DOMActivate
Occurs when an element becomes active.
DOMAttrModified
9
Fires when an attribute is added, removed or when the value of an attribute is modified by script.
DOMCharacterDataModified
9
Fires when a script changes the value of a TextNode.
DOMFocusIn
Occurs before an element receives focus.
DOMFocusOut
Occurs before an element loses the focus.
DOMMouseScroll
Occurs when the mouse wheel rolls.
DOMNodeInserted
9
Occurs on a node when it is added to an element.
DOMNodeInsertedIntoDocument
Occurs on a node when it is inserted into the document.
DOMNodeRemoved
9
Occurs on a node when it is removed from its parent.
DOMNodeRemovedFromDocument
Occurs on a node when it is removed from the document.
DOMSubtreeModified
9
Fires on a node when a modification occurs in the subtree that belongs to it.
dragdrop
3.5
Occurs on a possible target element when the dragged data is dropped on it.
dragexit
Occurs on an element when the user moves the mouse pointer out of it during a drag operation.
draggesture
Occurs on the source element when the user starts the drag operation.
overflow
Occurs when the contents or the size of an element is changed and it causes a scrollbar to appear.
overflowchanged
Occurs when the contents or the size of an element is changed and it causes a scrollbar to appear or disappear.
RadioStateChange
Occurs when the state of a radio button has changed.
underflow
Occurs when the contents or the size of an element is changed and it causes a scrollbar to disappear.
User Contributed Comments

Post Content

Post Content