HTML5 Events

State the different events used in HTML5.

Whenever a user visits any website they do things such as clicking on the text and images or the given links, hover over certain things etc. all these are examples of JavaScript call events.

These event handlers can be written in JavaScript or VBScript where you can specify the event handlers as a value of the event tag attribute.

Following are the list of event attributes which can be used with any JavaScript or VBScript code:

Event AttributeDescription
onabortIt triggers on an abort event.
onchangeIt triggers when an element changes.
oncontextmenuIt triggers when a context menu is triggered.
onerrorIt triggers when an error occurs.
onforminputIt triggers when a form gets user input.
onformchangeIt triggers when a form changes.
oninputIt triggers when an element gets the input from user.
oninvalidIt triggers when an element is invalid.
onmessageIt triggers when the message is triggered.
onreadystatechangeIt triggers when the ready-state changes.
onscrollIt triggers when an element's scrollbar is being scrolled.
onselectIt triggers when an element is selected.
onsubmitIt triggers when a form is submitted.

Drag and Drop events

Event AttributeDescription
ondragIt triggers when an element is dragged.
ondragenterIt triggers when an element has been dragged to a valid drop target.
ondragendIt triggers at the end of the drag operation.
ondragoverIt triggers when an element is being dragged over a valid drop target.
ondragleaveIt triggers when an element leaves a valid drop target.
ondragstartIt triggers at the start of a drag operation.
ondropIt triggers when dragged element is being dropped.

Loading data events

Event AttributeDescription
onloadIt triggers when the document loads.
onloadedmetadataIt triggers when the duration and other media data of a media element is loaded.
onloadeddataIt triggers when the media data is loaded.
onloadstartIt triggers when the browser starts to load the media data.

Mouse events

Event AttributeDescription
onclickIt triggers on a mouse click.
ondblclickIt triggers on a mouse double-click.
onmousemoveIt triggers when the mouse pointer moves.
onmousedownIt triggers when the mouse button is pressed.
onmouseoutIt triggers when the mouse pointer moves out of an element.
onmouseoverIt triggers when the mouse pointer moves over an element.
onmouseupIt triggers when a mouse button is released.
onmousewheelIt triggers when the mouse wheel is rotated.

Keypress events

Event AttributeDescription
onkeypressIt triggers when a key is pressed and released.
onkeyupIt triggers when a key is released.
onkeydownIt triggers when a key is pressed.

Document events

Event AttributeDescription
offlineIt triggers when the document goes offline.
onafterprintIt triggers after the document is printed.
onbeforeprintIt triggers before the document is printed.
onbeforeonloadIt triggers before the document loads.
onhaschangeIt triggers when the document has a change.
onofflineIt triggers when the document goes offline.
onoineIt triggers when the document comes online.
ononlineIt triggers when the document comes online.
onredoIt triggers when the document performs a redo.
onunloadIt triggers when the user leaves the document.
onundoIt triggers when a document performs an undo.
onstorageIt triggers when a document loads.

Window events

Event AttributeDescription
onblurIt triggers when the window loses focus.
onfocusIt triggers when the window gets a focus.
onpageshowIt triggers when the window becomes visible.
onpagehideIt triggers when the window is hidden.
onresizeIt triggers when the window is resized.
onpopstateIt triggers when the history of the window changes.

Media events

Event AttributeDescription
oncanplayIt triggers when the media can start play, but might stop for buffering.
oncanplaythroughIt triggers when media can be played till the end without stopping or buffering.
onemptiedIt triggers when a media resource element suddenly becomes empty.
ondurationchangeIt triggers when the length of the media is changed.
onendedIt triggers when the media reaches to an end.
onplayIt triggers when the media will start playing.
onpauseIt triggers when the media is paused.
onplayingIt triggers when media starts playing.
onprogressIt triggers when the browser is fetching the media data.
onratechangeIt triggers when the playing rate of media data has changed.
onseekedIt triggers when the media element's seeking attribute is no longer true and the seeking has begun.
onseekingIt triggers when the media element's seeking attribute is true and the seeking has begun.
onstalledIt triggers when there is an error in the fetching media data.
ontimeupdateIt triggers when media changes its playing position.
onsuspendIt triggers when the browser is fetching media data but stopped before the entire media file was fetched.
onwaitingIt triggers when the media has stopped playing, but is expected to resume.
onvolumechangeIt triggers when media changes the volume also when the volume is set to “mute”.