Events triggers the actions with the help of mouse click like we have in JavaScript. To define events action in HTML we have Global Event Attributes that are added to any HTML elements(tags).
In HTML we have several Events that are:
Window Events: Window Events Attributes are used to trigger the events for windows objects. Supported to only HTML Tag: <body>
Attributes:
onafterprint script Script to be run after the document is printed
<element onafterprint="script">
The script to be run on onafterprint
onbeforeprint script Script to be run before the document is printed
<element onbeforeprint="script">
The script to be run on onbeforeprint
onbeforeunload script Script to be run when the document is about to be unloaded
<element onbeforeunload="script">
The script to be run on onbeforeunload
onerror script Script to be run when an error occurs
<element onerror="script">
The script to be run on onerror
onhashchange script Script to be run when there has been changes to the anchor part of the a URL
<element onhashchange="script">
The script to be run on onhashchange
onload script Fires after the page is finished loading
<element onload="script">
The script to be run on onload
onmessage script Script to be run when the message is triggered
onoffline script Script to be run when the browser starts to work offline
<element onoffline="script">
The script to be run on onoffline
ononline script Script to be run when the browser starts to work online
<element ononline="script">
The script to be run on ononline
onpagehide script Script to be run when a user navigates away from a page
onpageshow script Script to be run when a user navigates to a page
<element onpageshow="script">
The script to be run on onpageshow
onpopstate script Script to be run when the window's history changes
onresize script Fires when the browser window is resized
<element onresize="script">
The script to be run on onresize
onstorage script Script to be run when a Web Storage area is updated
onunload script Fires once a page has unloaded (or the browser window has been closed)
<element onunload="script">
The script to be run on onunload
Form Events:
Attributes:
onblur script Fires the moment that the element loses focus
<element onblur="script">
The script to be run on onblur
onchange script Fires the moment when the value of the element is changed
<element onchange="script">
script The script to be run on onchange
oncontextmenu script Script to be run when a context menu is triggered
<element oncontextmenu="script">
The script to be run on oncontextmenu
onfocus script Fires the moment when the element gets focus
<element onfocus="script">
The script to be run on onfocus
oninput script Script to be run when an element gets user input
<element oninput="script">
The script to be run on oninput
oninvalid script Script to be run when an element is invalid
<element oninvalid="script">
The script to be run on oninvalid
onreset script Fires when the Reset button in a form is clicked
<element onreset="script">
The script to be run on onreset
onsearch script Fires when the user writes something in a search field (for <input="search">)
<element onsearch="script">
The script to be run on onsearch
onselect script Fires after some text has been selected in an element
<element onselect="script">
The script to be run on onselect
onsubmit script Fires when a form is submitted
<element onsubmit="script">
The script to be run on onsubmit
Keyboard Events:
onkeydown script Fires when a user is pressing a key
<element onkeydown="script">
The script to be run on onkeydown
onkeypress script Fires when a user presses a key
<element onkeypress="script">
script The script to be run on onkeypress
onkeyup script Fires when a user releases a key
<element onkeyup="script">
script The script to be run on onkeyup
Mouse Events:
onclick script Fires on a mouse click on the element
<element onclick="script">
The script to be run on onclick
ondblclick script Fires on a mouse double-click on the element
<element ondblclick="script">
The script to be run on ondblclick
onmousemove script Fires when the mouse pointer is moving while it is over an element
<element onmousemove="script">
The script to be run on onmousemove
onmousedown script Fires when a mouse button is pressed down on an element
<element onmousedown="script">
The script to be run on onmousedown
onmouseout script Fires when the mouse pointer moves out of an element
<element onmouseout="script">
The script to be run on onmouseout
onmouseover script Fires when the mouse pointer moves over an element
<element onmouseover="script">
The script to be run on onmouseover
onmouseup script Fires when a mouse button is released over an element
<element onmouseup="script">
The script to be run on onmouseup
onmousewheel script Deprecated. Use the onwheel attribute instead
<element onmousewheel="script">
The script to be run on onmousewheel
onwheel script Fires when the mouse wheel rolls up or down over an element
<element onwheel="script">
The script to be run on onwheel
Supports all HTML Tags
Drag Events: Supported all HTML Tags
ondrag script Script to be run when an element is dragged
<element ondrag="script">
The script to be run on ondrag
ondragend script Script to be run at the end of a drag operation
<element ondragend="script">
The script to be run on ondragend
ondragenter script Script to be run when an element has been dragged to a valid drop target
<element ondragenter="script">
The script to be run on ondragenter
ondragleave script Script to be run when an element leaves a valid drop target
<element ondragleave="script">
The script to be run on ondragleave
ondragover script Script to be run when an element is being dragged over a valid drop target
<element ondragover="script">
The script to be run on ondragover
ondragstart script Script to be run at the start of a drag operation
<element ondragstart="script">
The script to be run on ondragstart
ondrop script Script to be run when dragged element is being dropped
<element ondrop="script">
The script to be run on ondrop
onscroll script Script to be run when an element's scrollbar is being scrolled
<element onscroll="script">
The script to be run on onscroll
Clipboard Events: Supported all HTML Tags
oncopy script Fires when the user copies the content of an element
<element oncopy="script">
The script to be run on oncopy
oncut script Fires when the user cuts the content of an element
<element oncut="script">
The script to be run on oncut
onpaste script Fires when the user pastes some content in an element
<element onpaste="script">
The script to be run on onpaste
Media Events: Media events triggers the media audio,video,images and gets supported with all HTML tags but commonly with <audio>, <embed>, <img>, <object>, and <video>
onabort script Script to be run on abort
oncanplay script Script to be run when a file is ready to start playing (when it has buffered enough to begin)
oncanplaythrough script Script to be run when a file can be played all the way to the end without pausing for buffering
oncuechange script Script to be run when the cue changes in a <track> element
ondurationchange script Script to be run when the length of the media changes
onemptied script Script to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects)
onended script Script to be run when the media has reach the end (a useful event for messages like "thanks for listening")
onerror script Script to be run when an error occurs when the file is being loaded
onloadeddata script Script to be run when media data is loaded
onloadedmetadata script Script to be run when meta data (like dimensions and duration) are loaded
onloadstart script Script to be run just as the file begins to load before anything is actually loaded
onpause script Script to be run when the media is paused either by the user or programmatically
onplay script Script to be run when the media is ready to start playing
onplaying script Script to be run when the media actually has started playing
onprogress script Script to be run when the browser is in the process of getting the media data
onratechange script Script to be run each time the playback rate changes (like when a user switches to a slow motion or fast forward mode)
onseeked script Script to be run when the seeking attribute is set to false indicating that seeking has ended
onseeking script Script to be run when the seeking attribute is set to true indicating that seeking is active
onstalled script Script to be run when the browser is unable to fetch the media data for whatever reason
onsuspend script Script to be run when fetching the media data is stopped before it is completely loaded for whatever reason
ontimeupdate script Script to be run when the playing position has changed (like when the user fast forwards to a different point in the media)
onvolumechange script Script to be run each time the volume is changed which (includes setting the volume to "mute")
onwaiting script Script to be run when the media has paused but is expected to resume (like when the media pauses to buffer more data)
Misc Events:
ontoggle script Fires when the user opens or closes the <details> element
In HTML we have several Events that are:
Window Events: Window Events Attributes are used to trigger the events for windows objects. Supported to only HTML Tag: <body>
Attributes:
onafterprint script Script to be run after the document is printed
<element onafterprint="script">
The script to be run on onafterprint
<element onbeforeprint="script">
The script to be run on onbeforeprint
<element onbeforeunload="script">
The script to be run on onbeforeunload
onerror script Script to be run when an error occurs
<element onerror="script">
The script to be run on onerror
onhashchange script Script to be run when there has been changes to the anchor part of the a URL
<element onhashchange="script">
The script to be run on onhashchange
onload script Fires after the page is finished loading
<element onload="script">
The script to be run on onload
onmessage script Script to be run when the message is triggered
onoffline script Script to be run when the browser starts to work offline
<element onoffline="script">
The script to be run on onoffline
ononline script Script to be run when the browser starts to work online
<element ononline="script">
The script to be run on ononline
onpagehide script Script to be run when a user navigates away from a page
onpageshow script Script to be run when a user navigates to a page
<element onpageshow="script">
The script to be run on onpageshow
onpopstate script Script to be run when the window's history changes
onresize script Fires when the browser window is resized
<element onresize="script">
The script to be run on onresize
onstorage script Script to be run when a Web Storage area is updated
onunload script Fires once a page has unloaded (or the browser window has been closed)
<element onunload="script">
The script to be run on onunload
Form Events:
Attributes:
onblur script Fires the moment that the element loses focus
<element onblur="script">
The script to be run on onblur
| Supports all HTML tags: | EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title> |
|---|
<element onchange="script">
script The script to be run on onchange
| Supports HTML tags: | <input type="checkbox">, <input type="file">, <input type="password">, <input type="radio">, <input type="range">, <input type="search">, <input type="text">, <select> and <textarea> |
|---|
<element oncontextmenu="script">
The script to be run on oncontextmenu
onfocus script Fires the moment when the element gets focus
<element onfocus="script">
The script to be run on onfocus
| Supports all HTML tags: | EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title> |
|---|
<element oninput="script">
The script to be run on oninput
| Supported HTML tags: | <input type="password">, <input type="search">, <input type="text"> and <textarea> |
|---|
<element oninvalid="script">
The script to be run on oninvalid
| Supported HTML tags: | <input> |
|---|
<element onreset="script">
The script to be run on onreset
| Supported HTML tags: | <form> |
|---|
<element onsearch="script">
The script to be run on onsearch
| Supported HTML tags: | <input type="search"> |
|---|
<element onselect="script">
The script to be run on onselect
| Supported HTML tags: | <input type="file">, <input type="password">, <input type="text">, and <textarea> |
|---|
<element onsubmit="script">
The script to be run on onsubmit
| Supported HTML tags: | <form> |
|---|
Keyboard Events:
| Supports all HTML tags: | EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title> |
|---|
<element onkeydown="script">
The script to be run on onkeydown
onkeypress script Fires when a user presses a key
<element onkeypress="script">
script The script to be run on onkeypress
onkeyup script Fires when a user releases a key
<element onkeyup="script">
script The script to be run on onkeyup
Mouse Events:
| Supports all HTML tags: | EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title> |
|---|
<element onclick="script">
The script to be run on onclick
ondblclick script Fires on a mouse double-click on the element
<element ondblclick="script">
The script to be run on ondblclick
onmousemove script Fires when the mouse pointer is moving while it is over an element
<element onmousemove="script">
The script to be run on onmousemove
onmousedown script Fires when a mouse button is pressed down on an element
<element onmousedown="script">
The script to be run on onmousedown
onmouseout script Fires when the mouse pointer moves out of an element
<element onmouseout="script">
The script to be run on onmouseout
onmouseover script Fires when the mouse pointer moves over an element
<element onmouseover="script">
The script to be run on onmouseover
onmouseup script Fires when a mouse button is released over an element
<element onmouseup="script">
The script to be run on onmouseup
onmousewheel script Deprecated. Use the onwheel attribute instead
<element onmousewheel="script">
The script to be run on onmousewheel
onwheel script Fires when the mouse wheel rolls up or down over an element
<element onwheel="script">
The script to be run on onwheel
Supports all HTML Tags
Drag Events: Supported all HTML Tags
ondrag script Script to be run when an element is dragged
<element ondrag="script">
The script to be run on ondrag
ondragend script Script to be run at the end of a drag operation
<element ondragend="script">
The script to be run on ondragend
ondragenter script Script to be run when an element has been dragged to a valid drop target
<element ondragenter="script">
The script to be run on ondragenter
ondragleave script Script to be run when an element leaves a valid drop target
<element ondragleave="script">
The script to be run on ondragleave
ondragover script Script to be run when an element is being dragged over a valid drop target
<element ondragover="script">
The script to be run on ondragover
ondragstart script Script to be run at the start of a drag operation
<element ondragstart="script">
The script to be run on ondragstart
ondrop script Script to be run when dragged element is being dropped
<element ondrop="script">
The script to be run on ondrop
onscroll script Script to be run when an element's scrollbar is being scrolled
<element onscroll="script">
The script to be run on onscroll
| Supported HTML tags: | <address>, <blockquote>, <body>, <caption>, <center>, <dd>, <dir>, <div>, <dl>, <dt>, <fieldset>, <form>, <h1> to <h6>, <html>, <li>, <menu>, <object>, <ol>, <p>, <pre>, <select>, <tbody>, <textarea>, <tfoot>, <thead>, <ul> |
|---|
Clipboard Events: Supported all HTML Tags
oncopy script Fires when the user copies the content of an element
<element oncopy="script">
The script to be run on oncopy
oncut script Fires when the user cuts the content of an element
<element oncut="script">
The script to be run on oncut
onpaste script Fires when the user pastes some content in an element
<element onpaste="script">
The script to be run on onpaste
Media Events: Media events triggers the media audio,video,images and gets supported with all HTML tags but commonly with <audio>, <embed>, <img>, <object>, and <video>
onabort script Script to be run on abort
oncanplay script Script to be run when a file is ready to start playing (when it has buffered enough to begin)
oncanplaythrough script Script to be run when a file can be played all the way to the end without pausing for buffering
oncuechange script Script to be run when the cue changes in a <track> element
ondurationchange script Script to be run when the length of the media changes
onemptied script Script to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects)
onended script Script to be run when the media has reach the end (a useful event for messages like "thanks for listening")
onerror script Script to be run when an error occurs when the file is being loaded
onloadeddata script Script to be run when media data is loaded
onloadedmetadata script Script to be run when meta data (like dimensions and duration) are loaded
onloadstart script Script to be run just as the file begins to load before anything is actually loaded
onpause script Script to be run when the media is paused either by the user or programmatically
onplay script Script to be run when the media is ready to start playing
onplaying script Script to be run when the media actually has started playing
onprogress script Script to be run when the browser is in the process of getting the media data
onratechange script Script to be run each time the playback rate changes (like when a user switches to a slow motion or fast forward mode)
onseeked script Script to be run when the seeking attribute is set to false indicating that seeking has ended
onseeking script Script to be run when the seeking attribute is set to true indicating that seeking is active
onstalled script Script to be run when the browser is unable to fetch the media data for whatever reason
onsuspend script Script to be run when fetching the media data is stopped before it is completely loaded for whatever reason
ontimeupdate script Script to be run when the playing position has changed (like when the user fast forwards to a different point in the media)
onvolumechange script Script to be run each time the volume is changed which (includes setting the volume to "mute")
onwaiting script Script to be run when the media has paused but is expected to resume (like when the media pauses to buffer more data)
Misc Events:
ontoggle script Fires when the user opens or closes the <details> element
| Supported HTML tag: | <details> |
|---|
No comments:
Post a Comment