HTML Event Attributes
HTML Event Attributes
If a browser responds to the user behavior, an event is called. For example, if we click on the submit button, a box of details will appear on the screen.
There are lots of event attributes in HTML5 and programming languages, such as JavaScript.
The following is a table of event attributes allowing us to execute several events using those attributes.
Windows Event Attributes
For the window object, Windows events are linked. It can only added with < body > tag.
Attribute | Description |
On-after-print | After the document has been written, the script has executed. |
On-before-print | The script has executed before imprinting a document. |
On-before-unload | Before uploading a document, she executed the script. |
On-error | The script was executed when an error occurred. |
On-hash-change | When the anchor part in the webpage URL is changed, the script is executed. |
On-massage | The script was executed when a message occurs. |
On-offline | When the network connection is broken, the script was executed, and the browser started working offline. |
On-online | This script was executed when the browser began operating online. |
On-load | The script was executed when the webpage is fully loaded. |
On-page-hide | When the current web page is hidden, the script is executed. It appears as if the user had moved away from the current web page. |
On-page-show | Executed the script when focused primarily on the current website. |
On-resize | The script is executed when the window is resized. |
On-pop-state | The script is executed when the active history of the window is changed. |
On-unload | When the current webpage is removed, execute the file, or the window is closed. |
On-storage | The script was executed when web storage is modified. |
Form Event Attributes
Form event occurs when some activities are carried out by the user within the program, such as sending the request, selecting the input field, etc.
Events of form can be used for any element, but these are primarily used for aspects of HTML form.
The following is a list of all attributes for Form Events:
Attribute | Description |
Onblur | The script was executed when the form item loses focus. |
Onfocus | It triggers an event when it focuses on an element. |
Oninput | The script is executed when the user enters the element input. |
Onchange | When the element value is changed, the script is executed. |
Onreset | Triggers the event when the values for the form element are reset by the user. |
On-invalid | The script was executed when the element does not fulfill its predefined constraints. |
On-select | Triggers an event when any text has been selected by the user. |
On-search | Triggers an event when input is received from a search field. |
Onsubmit | Triggers the event when a form has been submitted. |
Keyboard Event Attributes
The event on the keyboard is when the user communicates with the keyboard. The Keyboard Events list below.
Attribute | Description |
Onkeydown | Triggers the event by pressing a key downwards on the keyboard. |
Onkeypress | Trigger the event by pressing the key that displays a particular character. |
Onkeyup | If the user releases the currently pressed key, trigger the event. |
Mouse Event Attributes
Attribute | Description |
Onmousedown | Activate the event when the item clicks on the mouse button. |
Onmousemove | Cause an event when the item is moving over the mouse pointer. |
Onclick | Trigger the event by clicking the mouse on the item. |
On-db-click | Trigger the event when the element is double-clicked on the mouse. |
Onmouseover | Trigger the event by moving the mouse on to the feature. |
Onmouseout | Trigger the event by moving the mouse outside of the feature. |
Onmouseup | Trigger event by mouse button release. |
On-wheel | Trigger the event if the mouse wheel rolls, up or down, over the object. |
Onmousewheel | It's deprecated. Using the onwheel attribute. |
Clipboard Event Attributes
Attribute | Description |
On-copy | Trigger an activity when the user copies the contents into the machine clipboard. |
Oncut | Trigger an event when the element's contents are cut into the clipboard and copied. |
Onpaste | Trigger the event by pasting any content into an item. |
Media Event Attribute
Attribute | Description |
Onabort | When media replay is aborted, this script was executed. |
Oncanplay | The script was executed when a media file is ready to play. |
Oncanplaythrough | The script was executed when the media file is ready to play without stopping or buffering. |
Ondurationchange | Execute a script when the duration of the media file is changed. |
Oncuechange | The text cue of the < track > element script is changed. |
Onemptied | Execute a script if a media error occurs, and the file becomes unavailable. |
Onended | The script was executed when its endpoint occurs in the media file. |
Onerror | The script was executed when an error occurred while the media data was being fetched. |
Onloadeddata | The script was executed while loading media data. |
Onloadedmetadata | The script is executed when the media file metadata is loaded. |
Onloadstart | The script was executed when loading of media file starts. |
Onpause | When the media playback is stopped, the script is executed. |
Onplay | When after being paused, the media file is ready to play, the script is executed. |
Onplaying | When a media file is started running, the script was executed. |
Onprogress | The script was executed when the user is in the process of obtaining the media info. |
Onratechange | When the playback speed was changed, the script executed. |
Onseeked | When the search for operation is over, the script is cleared, and the feature is searched. |
Onseeking | When the search operation is active, the script executed, and the search attribute set to true. |
Onstalled | The script was run when the browser suddenly stopped fetching data media. |
On-suspand | If fetching media data is intentionally stopped, the script is executed. |
Ontimeupdate | When the playback position is changed, the script executed as though a user fasts the track forward. |
Onvolumechange | The script is executed when the volume of media is changed (muted or unmuted). |
Onwaiting | If playback is paused to wait for more data to be loaded, the script executed. |