{"id":70,"date":"2022-03-19T10:25:48","date_gmt":"2022-03-19T10:25:48","guid":{"rendered":"https:\/\/staging.brightwhiz.com\/?post_type=topic&p=70"},"modified":"2022-03-19T10:25:49","modified_gmt":"2022-03-19T10:25:49","slug":"html-events-reference","status":"publish","type":"topic","link":"http:\/\/local.tutorials\/topic\/html-events-reference\/","title":{"rendered":"HTML – Events Reference"},"content":{"rendered":"\n
HTML adds interactivity with the user through events triggered based on actions in a web browser. Most of these events target JavScript script (event handlers) which can be programmed to do whatever the web developer needs it to do.<\/p>\n\n\n\n
The HTML 4.01 specification had defined 19 events. HTML5 added more events. Those which were introduced in HTML5 are labeled \u201cY<\/strong>\u201d in the tables below.<\/p>\n\n\n\n These are the global event attributes that can be added to HTML elements to define event actions.<\/p>\n\n\n\n These are the events triggered by the window object.<\/p>\n\n\n\n These events are triggered by actions inside an HTML form even though they may apply to almost all HTML elements outside form elements.<\/p>\n\n\n\n These events are triggered by actions on keyboard keys.<\/p>\n\n\n\n These events are triggered by actions on the mouse movement as well as button presses.<\/p>\n\n\n\n These events are triggered by actions on the mouse movements while keys are pressed on a particular element.<\/p>\n\n\n\n These events are triggered when data is added or retrieved from the Clipboard.<\/p>\n\n\n\n These events are triggered by actions on media like videos, images, and audio. They apply to all elements though it is most practical for use on elements such as audio, embed, img, object, and video.<\/p>\n\n\n\n <\/p>\n","protected":false},"excerpt":{"rendered":" HTML adds interactivity with the user through events triggered based on actions in a web browser. Most of these events target JavScript script (event handlers) which can be programmed to do whatever the web developer needs it to do. The HTML 4.01 specification had defined 19 events. HTML5 added more events. Those which were introduced […]<\/p>\n","protected":false},"featured_media":43,"comment_status":"open","ping_status":"closed","template":"","meta":[],"categories":[2],"tags":[],"subject":[7,9],"yoast_head":"\nWindow Events<\/h2>\n\n\n\n
Attribute<\/strong><\/th> HTML5<\/strong><\/th> Description<\/strong><\/th><\/tr><\/thead> onafterprint<\/td> Y<\/td> Triggers after a document is printed<\/td><\/tr> onbeforeprint<\/td> Y<\/td> Triggers before a document is printed<\/td><\/tr> onbeforeonload<\/td> Y<\/td> Triggers before a document loads<\/td><\/tr> onerror<\/td> Y<\/td> Triggers when an error occurs<\/td><\/tr> onhaschange<\/td> Y<\/td> Triggers when a document has changed<\/td><\/tr> onload<\/td> <\/td> Triggers when a document loads<\/td><\/tr> onmessage<\/td> Y<\/td> Triggers when a message is triggered<\/td><\/tr> onoffline<\/td> Y<\/td> Triggers when a document goes offline<\/td><\/tr> ononline<\/td> Y<\/td> Triggers when a document comes online<\/td><\/tr> onpagehide<\/td> Y<\/td> Triggers when a window is hidden<\/td><\/tr> onpageshow<\/td> Y<\/td> Triggers when a window becomes visible<\/td><\/tr> onpopstate<\/td> Y<\/td> Triggers when a window’s history changes<\/td><\/tr> onredo<\/td> Y<\/td> Triggers when a document performs a redo<\/td><\/tr> onresize<\/td> Y<\/td> Triggers when a window is resized<\/td><\/tr> onstorage<\/td> Y<\/td> Triggers when a document loads<\/td><\/tr> onundo<\/td> Y<\/td> Triggers when a document performs an undo<\/td><\/tr> onunload<\/td> <\/td> Triggers when a user leaves the document<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n Form Events<\/h2>\n\n\n\n
Attribute<\/strong><\/th> HTML5<\/strong><\/th> Description<\/strong><\/th><\/tr><\/thead> onblur<\/td> Y<\/td> Triggers when a window loses focus<\/td><\/tr> onchange<\/td> <\/td> Triggers when an element changes<\/td><\/tr> oncontextmenu<\/td> Y<\/td> Triggers when a context menu is triggered<\/td><\/tr> onfocus<\/td> <\/td> Triggers when a window gets focus<\/td><\/tr> onformchange<\/td> Y<\/td> Triggers when a form changes<\/td><\/tr> onforminput<\/td> Y<\/td> Triggers when a form gets user input<\/td><\/tr> oninput<\/td> Y<\/td> Triggers when an element gets user input<\/td><\/tr> oninvalid<\/td> Y<\/td> Triggers when an element is invalid<\/td><\/tr> onreset<\/td> <\/td> Triggers when a form is reset<\/td><\/tr> onselect<\/td> <\/td> Triggers when an element is selected<\/td><\/tr> onsubmit<\/td> <\/td> Triggers when a form is submitted<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n Keyboard Events<\/h2>\n\n\n\n
Attribute<\/strong><\/th> HTML5<\/strong><\/th> Description<\/strong><\/th><\/tr><\/thead> onkeydown<\/td> <\/td> Triggers when a key is pressed<\/td><\/tr> onkeypress<\/td> <\/td> Triggers when a key is pressed and released<\/td><\/tr> onkeyup<\/td> <\/td> Triggers when a key is released<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n Mouse Events<\/h2>\n\n\n\n
Attribute<\/strong><\/th> HTML5<\/strong><\/th> Description<\/strong><\/th><\/tr><\/thead> onclick<\/td> <\/td> Triggers on a mouse click<\/td><\/tr> ondblclick<\/td> <\/td> Triggers on a mouse double-click<\/td><\/tr> onmousedown<\/td> <\/td> Triggers when a mouse button is pressed<\/td><\/tr> onmousemove<\/td> <\/td> Triggers when the mouse pointer moves<\/td><\/tr> onmouseout<\/td> <\/td> Triggers when the mouse pointer moves out of an element<\/td><\/tr> onmouseover<\/td> <\/td> Triggers when the mouse pointer moves over an element<\/td><\/tr> onmouseup<\/td> <\/td> Triggers when a mouse button is released<\/td><\/tr> onmousewheel<\/td> <\/td> (Deprecated use onwheel) Triggers when the mouse wheel is being rotated<\/td><\/tr> onwheel<\/td> <\/td> Triggers when the mouse wheel is being rotated<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n Drag Events<\/h2>\n\n\n\n
Attribute<\/strong><\/th> HTML5<\/strong><\/th> Description<\/strong><\/th><\/tr><\/thead> ondrag<\/td> Y<\/td> Triggers when an element is dragged<\/td><\/tr> ondragend<\/td> Y<\/td> Triggers at the end of a drag operation<\/td><\/tr> ondragenter<\/td> Y<\/td> Triggers when an element has been dragged to a valid drop target<\/td><\/tr> ondragleave<\/td> Y<\/td> Triggers when an element leaves a valid drop target<\/td><\/tr> ondragover<\/td> Y<\/td> Triggers when an element is being dragged over a valid drop target<\/td><\/tr> ondragstart<\/td> Y<\/td> Triggers at the start of a drag operation<\/td><\/tr> ondrop<\/td> Y<\/td> Triggers when a dragged element is being dropped<\/td><\/tr> onscroll<\/td> Y<\/td> Triggers when an element’s scrollbar is being scrolled<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n Clipboard Events<\/h2>\n\n\n\n
Attribute<\/strong><\/th> HTML5<\/strong><\/th> Description<\/strong><\/th><\/tr><\/thead> oncopy<\/td> Y<\/td> Triggered when the user copies the content of an element<\/td><\/tr> oncut<\/td> Y<\/td> Triggered when the user cuts the content of an element<\/td><\/tr> onpaste<\/td> Y<\/td> Triggered when the user pastes some content in an element<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n Media Events<\/h2>\n\n\n\n
Attribute<\/th> HTML5<\/th> Description<\/th><\/tr><\/thead> onabort<\/td> Y<\/td> Triggers on an abort event<\/td><\/tr> oncanplay<\/td> Y<\/td> Triggers when a media can start play, but might has to stop for buffering<\/td><\/tr> oncanplaythrough<\/td> Y<\/td> Triggers when a media can be played to the end, without stopping for buffering<\/td><\/tr> ondurationchange<\/td> Y<\/td> Triggers when the length of a media is changed<\/td><\/tr> onemptied<\/td> Y<\/td> Triggers when a media resource element suddenly becomes empty<\/td><\/tr> onended<\/td> Y<\/td> Triggers when a media has reached the end<\/td><\/tr> onerror<\/td> Y<\/td> Triggers when an error occurs<\/td><\/tr> onloadeddata<\/td> Y<\/td> Triggers when media data is loaded<\/td><\/tr> onloadedmetadata<\/td> Y<\/td> Triggers when the duration and other media data of a media element is loaded<\/td><\/tr> onloadstart<\/td> Y<\/td> Triggers when the browser starts loading the media data<\/td><\/tr> onpause<\/td> Y<\/td> Triggers when media data is paused<\/td><\/tr> onplay<\/td> Y<\/td> Triggers when media data is going to start playing<\/td><\/tr> onplaying<\/td> Y<\/td> Triggers when media data has started playing<\/td><\/tr> onprogress<\/td> Y<\/td> Triggers when the browser is fetching the media data<\/td><\/tr> onratechange<\/td> Y<\/td> Triggers when the playing rate of media data has changed<\/td><\/tr> onreadystatechange<\/td> Y<\/td> Triggers when the ready-state changes<\/td><\/tr> onseeked<\/td> Y<\/td> Triggers when the seeking attribute of a media element is no longer true, and the seeking has ended<\/td><\/tr> onseeking<\/td> Y<\/td> Triggers when the seeking attribute of a media element is true, and the seeking has begun<\/td><\/tr> onstalled<\/td> Y<\/td> Triggers when there is an error in fetching media data<\/td><\/tr> onsuspend<\/td> Y<\/td> Triggers when the browser has been fetching media data, but stopped before the entire media file was fetched<\/td><\/tr> onvolumechange<\/td> Y<\/td> Triggers when a media changes the volume, also when the volume is set to “mute”<\/td><\/tr> ontimeupdate<\/td> Y<\/td> Triggers when media changes its playing position<\/td><\/tr> onwaiting<\/td> Y<\/td> Triggers when media has stopped playing but is expected to resume<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n Misc Events<\/h2>\n\n\n\n
Attribute<\/strong><\/th> HTML5<\/strong><\/th> Description<\/strong><\/th><\/tr><\/thead> ontoggle<\/td> Y<\/td> Triggered when the user opens or closes the details element<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n