Home >Web Front-end >Front-end Q&A >What are the html events?

What are the html events?

青灯夜游
青灯夜游Original
2021-06-15 15:28:555432browse

html events include: 1. Window events triggered by window objects; 2. Form events triggered by actions within HTML forms; 3. Keyboard events; 4. Mouse events triggered by mouse or similar user actions ;5. Media events triggered by media (such as videos, images, and audio).

What are the html events?

The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.

HTML has the ability to have events trigger actions in the browser, such as launching JavaScript when a user clicks on an element.

Events in html

1. Window events

Events triggered for the window object (applied to

tag):
Attribute Value Description
onafterprint script Script that runs after the document is printed.
onbeforeprint script Script that runs before document printing.
onbeforeunload script Script that runs before the document is unloaded.
onerror script Script that runs when an error occurs.
onhaschange script A script that runs when the document has changed.
onload script Triggered after the page has finished loading.
onmessage script Script that runs when a message is triggered.
onoffline script Script that runs when the document is offline.
ononline script Script that runs when the document goes online.
onpagehide script Script that runs when the window is hidden.
onpageshow script Script that runs when the window becomes visible.
onpopstate script Script that runs when the window history changes.
onredo script Script that runs when the document performs redo.
onresize script Fired when the browser window is resized.
onstorage script Script that runs after the Web Storage zone is updated.
onundo script Script that runs when the document executes undo.
onunload script Fires once the page has been downloaded (or the browser window has been closed).

2. Form event

An event triggered by an action within an HTML form (applies to almost all HTML elements, but most Commonly used in form elements):

##onblur scriptScript that runs when the element loses focus. onchangescriptScript that runs when the element value is changed. oncontextmenuscriptScript that runs when the context menu is triggered. onfocusscriptScript that runs when an element gets focus. onformchangescriptScript that runs when the form changes. onforminputscriptScript that runs when the form gets user input. oninputscriptA script that runs when the element gets user input. oninvalidscriptScript that runs when an element is invalid. onresetscriptFires when the reset button in the form is clicked. Not supported in HTML5. onselectscriptFires after the text in the element is selected. onsubmitscriptFires when the form is submitted.
Attribute Value Description

3. Keyboard event

AttributeValueDescriptiononkeydownscriptFires when the user presses a key. onkeypressscriptFires when the user taps the button. onkeyupscriptFires when the user releases the key.

4. Mouse event

Events triggered by mouse or similar user actions:

Properties Value Description
onclick script Fires when a mouse click occurs on the element.
ondblclick script Fires when a mouse double-click occurs on the element.
ondrag script Script that runs when the element is dragged.
ondragend script Script that runs at the end of a drag operation.
ondragenter script A script that runs when an element has been dragged into a valid drag and drop area.
ondragleave script Script that runs when an element leaves a valid drag-and-drop target.
ondragover script Script that runs when an element is being dragged on a valid drag target.
ondragstart script Script that runs at the beginning of a drag operation.
ondrop script Script that runs when the dragged element is being dragged and dropped.
onmousedown script Fires when the mouse button is pressed on the element.
onmousemove script Fires when the mouse pointer moves over an element.
onmouseout script Fires when the mouse pointer moves out of the element.
onmouseover script Fires when the mouse pointer moves over an element.
onmouseup script Fires when the mouse button is released on the element.
onmousewheel script Script that runs when the mouse wheel is being rolled.
onscroll script Script that runs when the element scroll bar is scrolled.

5. Media event

Events triggered by media (such as video, image and audio) (applicable to all HTML elements, but commonly found in media elements, such as

##AttributeValueDescriptiononabortscriptScript to run on exit. oncanplayscriptA script that runs when the file is ready to start playback (when buffering is sufficient to start). oncanplaythroughscriptA script that runs when the media is able to play to the end without stopping due to buffering. ondurationchangescriptScript that runs when the media length changes. onemptiedscriptA script that runs when a failure occurs and the file is suddenly unavailable (such as when the connection is unexpectedly dropped). onendedscriptA script that runs when the media has reached the end (can send a message like "Thanks for watching"). onerrorscriptScript that runs when an error occurs during file loading. onloadeddatascriptScript that runs when media data has been loaded. onloadedmetadatascriptScript that runs when metadata (such as resolution and duration) is loaded. onloadstartscriptA script that runs before the file starts loading and before any data is actually loaded. onpausescriptA script that runs when the media is paused by the user or program. onplayscriptScript that runs when the media is ready to start playing. onplayingscriptScript that runs when the media has started playing. onprogressscriptA script that runs when the browser is retrieving media data. onratechangescriptA script that runs whenever the playback rate changes (such as when the user switches to slow motion or fast forward mode). onreadystatechangescriptA script that runs whenever the ready state changes (the ready state monitors the status of media data). onseekedscriptScript that runs when the seeking property is set to false (indicating that seeking has ended). onseekingscriptA script that runs when the seeking property is set to true (indicating that positioning is active). onstalledscriptA script that runs when the browser fails to retrieve media data for whatever reason. onsuspendscriptA script that is run when retrieving media data is terminated for any reason before the media data is fully loaded. ontimeupdatescriptA script that runs when the playback position changes (such as when the user fast forwards to a different location in the media). onvolumechangescriptA script that runs whenever the volume changes (including setting the volume to silent). onwaitingscriptRun script when the media has stopped playing but intends to continue playing (such as when the media is paused to buffer more data)
For more programming-related knowledge, please visit:

Introduction to Programming! !

The above is the detailed content of What are the html events?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn