When users visit your website, they do things like click various links, bring mouse over text and images etc. These are examples of what we call events in JavaScript and VBScript terminologies.
We can write our event handlers using JavaScript or VBScript and can specify some actions to be taken against these events. Though these are the events but they will be specified as attributes for the HTML tags.
The HTML 4.01 specification had defined 19 events but later HTML-5 has added many other events which we have listed down here −
Following events have been introduced in older versions of HTML but all the tags marked with are part of HTML-5.
Events | HTML-5 | Description |
---|---|---|
onafterprint | Triggers after a document is printed | |
onbeforeprint | Triggers before a document is printed | |
onbeforeonload | Triggers before a document loads | |
onerror | Triggers when an error occurs | |
onhaschange | Triggers when a document has changed | |
onload | Triggers when a document loads | |
onmessage | Triggers when a message is triggered | |
onoffline | Triggers when a document goes offline | |
ononline | Triggers when a document comes online | |
onpagehide | Triggers when a window is hidden | |
onpageshow | Triggers when a window becomes visible | |
onpopstate | Triggers when a window's history changes | |
onredo | Triggers when a document performs a redo | |
onresize | Triggers when a window is resized | |
onstorage | Triggers when a document loads | |
onundo | Triggers when a document performs an undo | |
onunload | Triggers when a user leaves the document |
Following tags have been introduced in older versions of HTML but all the tags marked with are part of HTML-5.
Events | HTML-5 | Description |
---|---|---|
onblur | Triggers when a window loses focus | |
onchange | Triggers when an element changes | |
oncontextmenu | Triggers when a context menu is triggered | |
onfocus | Triggers when a window gets focus | |
onformchange | Triggers when a form changes | |
onforminput | Triggers when a form gets user input | |
oninput | Triggers when an element gets user input | |
oninvalid | Triggers when an element is invalid | |
onreset | Triggers when a form is reset | |
onselect | Triggers when an element is selected | |
onsubmit | Triggers when a form is submitted |
Events | HTML-5 | Description |
---|---|---|
onkeydown | Triggers when a key is pressed | |
onkeypress | Triggers when a key is pressed and released | |
onkeyup | Triggers when a key is released |
Following tags have been introduced in older versions of HTML but all the tags marked with are part of HTML-5.
Events | HTML-5 | Description |
---|---|---|
onclick | Triggers on a mouse click | |
ondblclick | Triggers on a mouse double-click | |
ondrag | Triggers when an element is dragged | |
ondragend | Triggers at the end of a drag operation | |
ondragenter | Triggers when an element has been dragged to a valid drop target | |
ondragleave | Triggers when an element leaves a valid drop target | |
ondragover | Triggers when an element is being dragged over a valid drop target | |
ondragstart | Triggers at the start of a drag operation | |
ondrop | Triggers when a dragged element is being dropped | |
onmousedown | Triggers when a mouse button is pressed | |
onmousemove | Triggers when the mouse pointer moves | |
onmouseout | Triggers when the mouse pointer moves out of an element | |
onmouseover | Triggers when the mouse pointer moves over an element | |
onmouseup | Triggers when a mouse button is released | |
onmousewheel | Triggers when the mouse wheel is being rotated | |
onscroll | Triggers when an element's scrollbar is being scrolled |
Following tags have been introduced in older versions of HTML but all the tags marked with are part of HTML-5.
Events | HTML-5 | Description |
---|---|---|
onabort | Triggers on an abort event | |
oncanplay | Triggers when a media can start play, but might has to stop for buffering | |
oncanplaythrough | Triggers when a media can be played to the end, without stopping for buffering | |
ondurationchange | Triggers when the length of a media is changed | |
onemptied | Triggers when a media resource element suddenly becomes empty. | |
onended | Triggers when a media has reached the end | |
onerror | Triggers when an error occurs | |
onloadeddata | Triggers when media data is loaded | |
onloadedmetadata | Triggers when the duration and other media data of a media element is loaded | |
onloadstart | Triggers when the browser starts loading the media data | |
onpause | Triggers when media data is paused | |
onplay | Triggers when media data is going to start playing | |
onplaying | Triggers when media data has started playing | |
onprogress | Triggers when the browser is fetching the media data | |
onratechange | Triggers when the playing rate of media data has changed | |
onreadystatechange | Triggers when the ready-state changes | |
onseeked | Triggers when the seeking attribute of a media element is no longer true, and the seeking has ended | |
onseeking | Triggers when the seeking attribute of a media element is true, and the seeking has begun | |
onstalled | Triggers when there is an error in fetching media data | |
onsuspend | Triggers when the browser has been fetching media data, but stopped before the entire media file was fetched | |
ontimeupdate | Triggers when media changes its playing position | |
onvolumechange | Triggers when a media changes the volume, also when volume is set to "mute" | |
onwaiting | Triggers when media has stopped playing, but is expected to resume |