{"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

Window Events<\/h2>\n\n\n\n

These are the events triggered by the window object.<\/p>\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

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

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

These events are triggered by actions on keyboard keys.<\/p>\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

These events are triggered by actions on the mouse movement as well as button presses.<\/p>\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

These events are triggered by actions on the mouse movements while keys are pressed on a particular element.<\/p>\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

These events are triggered when data is added or retrieved from the Clipboard.<\/p>\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

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

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

<\/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":"\nHTML - Events Reference<\/title>\n<meta name=\"description\" content=\"This HTML 5 tutorial presents this updated HTML events reference for your convenience to download or to read online as needed\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/local.tutorials\/topic\/html-events-reference\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HTML - Events Reference\" \/>\n<meta property=\"og:description\" content=\"This HTML 5 tutorial presents this updated HTML events reference for your convenience to download or to read online as needed\" \/>\n<meta property=\"og:url\" content=\"http:\/\/local.tutorials\/topic\/html-events-reference\/\" \/>\n<meta property=\"og:site_name\" content=\"Brightwhiz.com Tutorials and Courses\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/brightwhiz\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-19T10:25:49+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/local.tutorials\/wp-content\/uploads\/2022\/03\/tutorial-html5.png\" \/>\n\t<meta property=\"og:image:width\" content=\"640\" \/>\n\t<meta property=\"og:image:height\" content=\"360\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@brightwhizmag\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/local.tutorials\/topic\/html-events-reference\/\",\"url\":\"http:\/\/local.tutorials\/topic\/html-events-reference\/\",\"name\":\"HTML - Events Reference\",\"isPartOf\":{\"@id\":\"http:\/\/local.tutorials\/#website\"},\"datePublished\":\"2022-03-19T10:25:48+00:00\",\"dateModified\":\"2022-03-19T10:25:49+00:00\",\"description\":\"This HTML 5 tutorial presents this updated HTML events reference for your convenience to download or to read online as needed\",\"breadcrumb\":{\"@id\":\"http:\/\/local.tutorials\/topic\/html-events-reference\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/local.tutorials\/topic\/html-events-reference\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/local.tutorials\/topic\/html-events-reference\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/local.tutorials\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"http:\/\/local.tutorials\/topic\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"HTML – Events Reference\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/local.tutorials\/#website\",\"url\":\"http:\/\/local.tutorials\/\",\"name\":\"Brightwhiz.com Tutorials and Courses\",\"description\":\"\",\"publisher\":{\"@id\":\"http:\/\/local.tutorials\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/local.tutorials\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/local.tutorials\/#organization\",\"name\":\"Brightwhiz.com\",\"url\":\"http:\/\/local.tutorials\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/local.tutorials\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/staging.brightwhiz.com\/wp-content\/uploads\/2022\/03\/brightwhiz-com-logo-orange.png\",\"contentUrl\":\"https:\/\/staging.brightwhiz.com\/wp-content\/uploads\/2022\/03\/brightwhiz-com-logo-orange.png\",\"width\":706,\"height\":135,\"caption\":\"Brightwhiz.com\"},\"image\":{\"@id\":\"http:\/\/local.tutorials\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/brightwhiz\",\"https:\/\/twitter.com\/brightwhizmag\",\"https:\/\/www.instagram.com\/glamorglaze\/\",\"https:\/\/www.pinterest.com\/sobbayi\/\",\"https:\/\/www.youtube.com\/c\/Sobbayi\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HTML - Events Reference","description":"This HTML 5 tutorial presents this updated HTML events reference for your convenience to download or to read online as needed","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/local.tutorials\/topic\/html-events-reference\/","og_locale":"en_US","og_type":"article","og_title":"HTML - Events Reference","og_description":"This HTML 5 tutorial presents this updated HTML events reference for your convenience to download or to read online as needed","og_url":"http:\/\/local.tutorials\/topic\/html-events-reference\/","og_site_name":"Brightwhiz.com Tutorials and Courses","article_publisher":"https:\/\/www.facebook.com\/brightwhiz","article_modified_time":"2022-03-19T10:25:49+00:00","og_image":[{"width":640,"height":360,"url":"http:\/\/local.tutorials\/wp-content\/uploads\/2022\/03\/tutorial-html5.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@brightwhizmag","twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/local.tutorials\/topic\/html-events-reference\/","url":"http:\/\/local.tutorials\/topic\/html-events-reference\/","name":"HTML - Events Reference","isPartOf":{"@id":"http:\/\/local.tutorials\/#website"},"datePublished":"2022-03-19T10:25:48+00:00","dateModified":"2022-03-19T10:25:49+00:00","description":"This HTML 5 tutorial presents this updated HTML events reference for your convenience to download or to read online as needed","breadcrumb":{"@id":"http:\/\/local.tutorials\/topic\/html-events-reference\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/local.tutorials\/topic\/html-events-reference\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/local.tutorials\/topic\/html-events-reference\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/local.tutorials\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"http:\/\/local.tutorials\/topic\/"},{"@type":"ListItem","position":3,"name":"HTML – Events Reference"}]},{"@type":"WebSite","@id":"http:\/\/local.tutorials\/#website","url":"http:\/\/local.tutorials\/","name":"Brightwhiz.com Tutorials and Courses","description":"","publisher":{"@id":"http:\/\/local.tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/local.tutorials\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/local.tutorials\/#organization","name":"Brightwhiz.com","url":"http:\/\/local.tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/local.tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/staging.brightwhiz.com\/wp-content\/uploads\/2022\/03\/brightwhiz-com-logo-orange.png","contentUrl":"https:\/\/staging.brightwhiz.com\/wp-content\/uploads\/2022\/03\/brightwhiz-com-logo-orange.png","width":706,"height":135,"caption":"Brightwhiz.com"},"image":{"@id":"http:\/\/local.tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/brightwhiz","https:\/\/twitter.com\/brightwhizmag","https:\/\/www.instagram.com\/glamorglaze\/","https:\/\/www.pinterest.com\/sobbayi\/","https:\/\/www.youtube.com\/c\/Sobbayi"]}]}},"_links":{"self":[{"href":"http:\/\/local.tutorials\/wp-json\/wp\/v2\/topic\/70"}],"collection":[{"href":"http:\/\/local.tutorials\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"http:\/\/local.tutorials\/wp-json\/wp\/v2\/types\/topic"}],"replies":[{"embeddable":true,"href":"http:\/\/local.tutorials\/wp-json\/wp\/v2\/comments?post=70"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/local.tutorials\/wp-json\/wp\/v2\/media\/43"}],"wp:attachment":[{"href":"http:\/\/local.tutorials\/wp-json\/wp\/v2\/media?parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/local.tutorials\/wp-json\/wp\/v2\/categories?post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/local.tutorials\/wp-json\/wp\/v2\/tags?post=70"},{"taxonomy":"subject","embeddable":true,"href":"http:\/\/local.tutorials\/wp-json\/wp\/v2\/subject?post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}