HTML Event Attributes

❮ Previous Reference Next ❯

Meaning

HTML Events run actions in a browser, like starting a JavaScript when a user clicks on an element.

Window Events

Events related to the window object (applies to the <body> element

Form Events

Events that occur due to the user interacting with the HTML form controls.

Mouse Events

Events that occur due to the user interacting with a pointing device such as a mouse.

Keyboard Events

Events that occur by the user interaction with the keyboard.

Clipboard Events

Events related to modification of the clipboard, that is copy, cut and paste:

Media Events

Events that occur when handling media elements that are embedded inside the HTML documents, such as <audio> and <video> elements.

Event Value Description Category
onafterprint script Specifies the script to be run after the document is printed. Window Event Attributes
onbeforeprint script Specifies the script to be run before the document is printed. Window Event Attributes
onbeforeunload script Specifies the script to be run when the document is about to be unloaded. Window Event Attributes
onerror script Specifies the script to be run when an error occurs. Window Event Attributes
onhashchange script Specifies the script to be run when there has been changes to the anchor part of the a URL. Window Event Attributes
onload script Specifies the script to be run after the page is finished loading. Window Event Attributes
onmessage script Specifies the script to be run when the message is triggered. Window Event Attributes
onoffline script Specifies the script to be run when the browser starts to work offline. Window Event Attributes
ononline script Specifies the script to be run when the browser starts to work online. Window Event Attributes
onpagehide script Specifies the script to be run when a user navigates away from a page. Window Event Attributes
onpageshow script Specifies the script to be run when a user navigates to a page. Window Event Attributes
onpopstate script Specifies the script to be run when the window's history changes. Window Event Attributes
onresize script Specifies the script to be run when the browser window is resized. Window Event Attributes
onstorage script Specifies the script to be run when a Web Storage is changed. Window Event Attributes
onunload script Specifies the script to be run once a page has unloaded or the browser window has been closed. Window Event Attributes
onblur script Specifies the script to be run the moment that the element loses focus. Form Events
onchange script Specifies the script to be run the moment when the value of the element is changed. Form Events
oncontextmenu script HTML5. Specifies the script to be run when a context menu is triggered Form Events
onfocus script Specifies the script to be run the moment when the element gets focus Form Events
oninput script Fires when the value of an element is changed by the user. Form Events
oninvalid script HTML5. Specifies the script to be run when an element is invalid. Form Events
onreset script HTML5. Specifies the script to be run when the user resets a form. Form Events
onsearch script Specifies the script to be run when the user writes something in a search field. Form Events
onselect script Specifies the script to be run after some text has been selected in an element. Form Events
onsubmit script Specifies the script to be run when a form is submitted. Form Events
onkeydown script Specifies the script to be run when a user is pressing a key. Keyboard Events
onkeypress script Specifies the script to be run when a user presses a key. Keyboard Events
onkeyup script Specifies the script to be run when a user releases a key. Keyboard Events
onclick script Specifies the script to be run on a mouse click on the element. Mouse Events
ondblclick script Specifies the script to be run on a mouse double-click on the element. Mouse Events
onmousedown script Specifies the script to be run when a mouse button is pressed down on an element. Mouse Events
onmousemove script Specifies the script to be run when the mouse pointer is moving while it is over an element. Mouse Events
onmouseout script Specifies the script to be run when the mouse pointer moves out of an element. Mouse Events
onmouseover script Specifies the script to be run when the mouse pointer moves over an element. Mouse Events
onmouseup script Specifies the script to be run when a mouse button is released over an element. Mouse Events
onmousewheel script Deprecated. Use the onwheel attribute instead. Mouse Events
onwheel script HTML5. Specifies the script to be run when the mouse wheel rolls up or down over an element. Mouse Events
ondrag script HTML5. Specifies the script to be run when an element is dragged. Drag Events
ondragend script HTML5. Specifies the script to be run at the end of a drag operation Drag Events
ondragenter script HTML5. Specifies the script to be run when an element has been dragged to a valid drop target Drag Events
ondragleave script HTML5. Specifies the script to be run when an element leaves a valid drop target Drag Events
ondragover script HTML5. Specifies the script to be run when an element is being dragged over a valid drop target Drag Events
ondragstart script HTML5. Specifies the script to be run at the start of a drag operation Drag Events
ondrop script HTML5. Specifies the script to be run when dragged element is being dropped Drag Events
onscroll script HTML5. Specifies the script to be run when an element's scrollbar is being scrolled Drag Events
oncopy script Specifies the script to be run when the user copies the content of an element. Clipboard Events
oncut script Specifies the script to be run when the user cuts the content of an element. Clipboard Events
onpaste script Specifies the script to be run when the user pastes some content in an element. Clipboard Events
onabort script HTML5. Specifies the script to be run on abort. Media Events
oncanplay script HTML5. Specifies the script to be run when a file is ready to start playing. Media Events
oncanplaythrough script HTML5. Specifies the script to be run when a file can be played all the way to the end without pausing for buffering. Media Events
oncuechange script HTML5. Specifies the script to be run when the cue changes in a <track> element. Media Events
ondurationchange script HTML5. Specifies the script to be run when the length of the media changes. Media Events
onemptied script HTML5. Specifies the script to be run when something bad happens and the file is suddenly unavailable. Media Events
onended script HTML5. Specifies the script to be run when the media has reach the end. Media Events
onerror script HTML5. Specifies the script to be run when an error occurs when the file is being loaded. Media Events
onloadeddata script HTML5. Specifies the script to be run when media data is loaded. Media Events
onloadedmetadata script HTML5. Specifies the script to be run when meta data (like dimensions and duration) are loaded. Media Events
onloadstart script HTML5. Specifies the script to be run just as the file begins to load before anything is actually loaded. Media Events
onpause script HTML5. Specifies the script to be run when the media is paused either by the user or programmatically. Media Events
onplay script HTML5. Specifies the script to be run when the media is ready to start playing. Media Events
onplaying script HTML5. Specifies the script to be run when the media actually has started playing. Media Events
onprogress script HTML5. Specifies the script to be run when the browser is in the process of getting the media data. Media Events
onratechange script HTML5. Specifies the script to be run each time the playback rate changes. Media Events
onseeked script HTML5. Specifies the script to be run when the seeking attribute is set to false indicating that seeking has ended. Media Events
onseeking script HTML5. Specifies the script to be run when the seeking attribute is set to true indicating that seeking is active. Media Events
onstalled script HTML5. Specifies the script to be run when the browser is unable to fetch the media data for whatever reason. Media Events
onsuspend script HTML5. Specifies the script to be run when fetching the media data is stopped before it is completely loaded for whatever reason. Media Events
ontimeupdate script HTML5. Specifies the script to be run when the playing position has changed Media Events
onvolumechange script HTML5. Specifies the script to be run each time the volume is changed which includes setting the volume to "mute". Media Events
onwaiting script HTML5. Specifies the script to be run when the media has paused but is expected to resume. Media Events
onshow script HTML5. Specifies the script to be run when the <menu> is shown as a context menu. Miscellaneous Event Attributes
ontoggle script HTML5. Specifies the script to be run when the user opens or closes the <details> element. Miscellaneous Event Attributes
❮ Previous Reference Next ❯