JavaScripts interaction with HTML is handled through events that occur when the user or the browser manipulates a page.
When the page loads, it is called an event. When the user clicks a button, that clicks to is an event. Other examples include events like pressing any key, closing a window, resizing a window, etc.
Developers can use these events to execute JavaScript coded responses, which cause buttons to close windows, messages to be displayed to users, data to be validated, and virtually any other type of response imaginable.
Some of the standard HTML 5 events are listed below −
Attribute | Value | Description |
Offline | script | Triggers when the document goes offline |
Onabort | script | Triggers on an abort event |
Onafterprint | script | Triggers after the document is printed |
onbeforeonload | script | Triggers before the document loads |
onbeforeprint | script | Triggers before the document is printed |
Onblur | script | Triggers when the window loses focus |
Oncanplay | script | Triggers when media can start play but might have to stop for buffering |
oncanplaythrough | script | Triggers when media can be played to the end, without stopping for buffering |
Onchange | script | Triggers when an element changes |