HTML events | rookie tutorial

Superplasticizer in concrete 2021-07-20 08:38 64
HTML event attribute global event attribute

one of the new features of HTML 4 is that it enables HTML events to trigger behavior in the browser, for example, when a user clicks an HTML element, it starts a section of JavaScript

if you want to learn more about event properties, please visit the table below JavaScript tutorial

to provide standard event properties that can be inserted into HTML / XHTML elements to define event behavior

New : New attribute event in HTML5

Window event attributes

is triggered by the window (for% 26lt; body> Label):

attribute value describes onafterprintnewscript running script after printing document onbeforeprintnewscript running script before printing document onbeforeonloadnewscript running script before loading document onbluescript running script when window loses focus onerornewscript running script when error occurs onfocusscript running script when window gets focus onhashchangenew Script run script onloadscript when document changes run script onmessagenewscript when document is loaded run script onofflinenewscript when message is triggered run script ononlinenewscript when document is offline run script onpagehidewscript when document is online run script onpageshownewscript when window is hidden run script onpopstatenewscript when window is visible Run the script onredo newscript when the history changes. Run the script onresce newscript when the document is redo. Run the script onStorage newscript when the window size is adjusted. Run the script onundonewscript when the web storage area is updated (when the data in the storage space changes). Run the script onunloadnewscript when the document is undone. Run the script onunloadnewscript when the user leaves the document Script form events (form events)

form events are triggered in HTML forms (applicable to all HTML elements, But the HTML element needs to be in the form):

attribute value describes onbluescript. When the element loses the focus, run the script onchangescript. When the element changes, run the script oncontextmenu newscript. When the context menu is triggered, run the script onfocusscript. When the element gets the focus, run the script onformingenewscript. When the form changes, run the script onforminput newscript Run the script oninputnewscript when the user input is received. Run the script oninvalidnewscript when the element is invalid. Run the script onresetscript when the form is reset. HTML 5 is not supported. Onselectscript run script when element is selected onsubmitscript run script when form is submitted keyboard events attribute value description onkeydownscript run script when key is pressed onkeypressscript run script when key is pressed and released onkeyupscript run script when key is released mouse events

trigger event by mouse, Similar to user behavior:

attribute value describes onclickscript running script when clicking mouse ondbllickscript running script when double clicking mouse ondragnewscript running script when dragging element ondragendnewscript running script when dragging operation ends ondragendnewscript running script when element is dragged to valid drag and drop target ondragleavenewscript running script when element leaves valid drag and drop target Run the script ondragovernewscript when the element is dragged above a valid drag and drop target. Run the script ondragstartnewscript when the drag operation starts. Run the script ondropnewscript when the element is being dragged. Run the script onmousedownscript when the mouse button is pressed. Run the script onmousemovescript when the mouse pointer moves Run the script onmouseverscript when the mouse pointer moves out of the element. Run the script onmousescript when the mouse pointer moves over the element. Run the script onmousewheelnewscript when the mouse button is released. Run the script onscrollnewscript when the mouse wheel is turned. Run the script media events

when the scroll bar of the element is scrolled, This event is triggered by images or audio, which are mostly used for HTML media elements, such as% 26lt; audio>, % 26lt; embed>, % 26lt; img>, % 26lt; object>, And% 26lt; video>:

The attribute value describes onabortscript. When an abort event occurs, run the script oncanplaynewscript. When the media can start playing but may need to stop due to buffering, run the script oncanplaythroughnewscript. When the media can stop playing to the end without buffering, run the script on durationchangenewscript. When the media length changes, run the script onemptied newscript When the resource element is suddenly empty (network error Run the script onendednewscript when the media has reached the end. Run the script onerrornewscript when an error occurs during the element loading. Run the script onloadeddata newscript when the media data is loaded. Run the script onloadedtadata newscript when the duration of the media element and other media data have been loaded. Run the script onloadstart newscript when the browser is open Run the script onpausewscript when the media data starts to load. Run the script onplaynewscript when the media data is suspended. Run the script onplayingnewscript when the media data is about to start playing. Run the script onprogress newscript when the media data has started playing. Run the script onratechangenewscript when the browser is fetching the media data. Run the script when the playback rate of the media data changes The script onreadystatechangenewscript runs the script onseekednewscript when the ready state changes. The script onseekingnewscript runs when the location attribute [1] of the media element is no longer true and the location has ended. The script onstallednewscript runs when the location attribute of the media element is true and the location has started. It runs when there is an error (delay) in retrieving the media data Line script onsuspend newscript runs the script ontimeupdate newscript when the browser has fetched media data but stopped before retrieving the entire media file. It runs the script onvolumechange newscript when the media changes its playback position. It runs the script onwaitingnewscript when the media changes its volume or when the volume is set to mute. It runs when the media has stopped playing but intends to continue playing Script other event property values description onshownewscript when% 26lt; menu> Element triggers ontogglenewscript when the user opens or closes% 26lt; details> Element