When a browser reacts on user action, then it is called as an event. For example, when we click on the submit button, then browser displays an alert box.
In HTML5 there are lots of event attributes available which can be activated using a programming language such as JavaScript.
Following is a table of event attributes, using these attributes we can perform several events.
Windows events are related for the window object, and it can only be applied with tag.
Attribute Name | Explanation |
---|---|
onerror | Executed the script when an error occurs. |
onload | Executed the script when the webpage is entirely loaded. |
onbeforeunload | Executed the script before a document being unloaded. |
onmessage | Executed the script when a message event occurs. |
onafterprint | Executed the script after the document is printed. |
onbeforeprint | Executed the script before the document is printed. |
onoffline | Executed the script when the network connection is disconnected, and browser started working offline. |
ononline | Executed the script when the browser started working online |
onstorage | Executed the script when web storage is updated. |
onunload | Executed the script when the current webpage is unloaded, or window is closed. |
onhashchange | Executed the script when the anchor part in URL of the webpage is changed. |
onpagehide | Executed the script when the current webpage is hidden such as if the user has moved away from the current webpage. |
onpageshow | Executed the script when the current webpage is focused. |
onpopstate | Executed the script when the window's active history is changed. |
onresize | Executed the script when the window is resized. |
Form event occurs when the user performs some action within the form such as submitting the form, selecting input field, etc.
The form events can be used with any element, but these are mainly used with HTML form elements.
Attribute Names | Explanation |
---|---|
onchange | Executed the script when the value of the element is changed. |
onsubmit | Triggers the event when a form is submitted. |
onblur | Executed the script when form element loses the focus. |
onfocus | Trigger an event when the element gets focused. |
oninput | Executed the script when the user enters input to the element. |
onsearch | Triggers the event when a search field receives some input. |
onselect | Triggers the event when the user has selected some text. |
oninvalid | Executed the script when the element does not satisfy its predefined constraints. |
onreset | Triggers the event when user reset the form element values. |
Following is the list of all Form Event attributes:
Attribute Names | Explanation |
---|---|
onclick | Trigger the event when the mouse clicks on the element. |
ondblclick | Trigger the event when mouse double-click occurs on the element. |
onmousedown | Trigger the event when the mouse button is pressed on the element. |
onmousemove | Trigger the event when the mouse pointer moves over the element. |
onmouseout | Trigger the event when the mouse moves outside the element. |
onmouseover | Trigger the event when the mouse moves onto the element. |
onmouseup | Trigger the event when the mouse button is released. |
onmousewheel | Deprecated. Use the onwheel attribute. |
onwheel | Trigger the event when the mouse wheel rolls up or down on the element |
HTML provides several mouse event attributes that allow us to handle various mouse-related interactions on elements.
Attribute Names | Explaination |
---|---|
onkeypress | Trigger the event when the user presses the key which displays some character. |
onkeyup | Trigger the event when the user releases the currently pressed key. |
onkeydown | Triggers the event when the user presses down a key on the keyboard. |
These attributes are often used in conjunction with JavaScript to execute specific actions or functions when a user interacts with a webpage using a mouse
Keyboard event occurs when a user interacts with the keyboard. Following is a list of the Keyboard event.