Learning notes: JavaScript body common events

Source: Internet
Author: User
Tags html form

Window Event Properties

Events triggered for the Window object (applied to <body> tags):

Properties value Description
Onafterprint Script A script that runs after the document is printed.
Onbeforeprint Script A script that runs before the document is printed.
onBeforeUnload Script The script that runs before the document is unloaded.
OnError Script A script that runs when an error occurs.
Onhaschange Script The script that runs when the document has changed.
OnLoad Script Triggered after the page finishes loading.
OnMessage Script The script that runs when the message is triggered.
Onoffline Script A script that runs when the document is offline.
Ononline Script The script that runs when the document is online.
Onpagehide Script The script that runs when the window is hidden.
Onpageshow Script The script that is run when the window becomes visible.
Onpopstate Script The script that runs when the window history changes.
Onredo Script The script that is run when the document is executed for revocation (redo).
OnResize Script triggered when the browser window is resized.
Onstorage Script Scripts that run after the Web Storage zone is updated.
OnUndo Script The script that runs when the document executes undo.
OnUnload Script Triggered once the page has been downloaded (or the browser window has been closed).
Form Event

Events triggered by actions within an HTML form (applied to almost all HTML elements, but most commonly in form elements):

Properties value Description
Onblur Script The script that runs when the element loses focus.
OnChange Script A script that runs when the element value is changed.
OnContextMenu Script The script that is run when the context menu is triggered.
onfocus Script The script that runs when the element gets focus.
Onformchange Script A script that runs when the form changes.
Onforminput Script The script that is run when the form obtains user input.
Oninput Script The script that is run when the element obtains user input.
Oninvalid Script The script to run when the element is invalid.
OnReset Script triggered when the reset button in the form is clicked. Not supported in HTML5.
Onselect Script triggered when the text in the element is selected.
OnSubmit Script Triggered when the form is submitted.
Keyboard Events
Properties value Description
OnKeyDown Script Triggered when the user presses the key.
onkeypress Script Triggered when the user taps the button.
OnKeyUp Script Triggered when the user releases the key.
Mouse Events

Events triggered by a mouse or similar user action:

Properties value Description
OnClick Script triggered when a mouse click occurs on an element.
OnDblClick Script triggered when a mouse double-click occurs on an element.
Ondrag Script The script that is run when the element is dragged.
Ondragend Script A script that runs at the end of a drag operation.
OnDragEnter Script A script that runs when an element element has been dragged into a valid drop area.
OnDragLeave Script The script that runs when the element leaves a valid drag-and-drop target.
OnDragOver Script The script that runs when the element is being dragged on a valid drag-and-drop target.
Ondragstart Script The script that runs at the beginning of the drag operation.
OnDrop Script The script that is run when the dragged element is being dragged and dropped.
OnMouseDown Script triggered when the mouse button is pressed on the element.
OnMouseMove Script triggered when the mouse pointer moves over an element.
onmouseout Script triggered when the mouse pointer moves out of the element.
onmouseover Script triggered when the mouse pointer moves over an element.
OnMouseUp Script triggered when the mouse button is released on the element.
OnMouseWheel Script The script that runs when the mouse wheel is being scrolled.
Onscroll Script The script that is run when the element scroll bar is scrolled.
Media Events

Events triggered by media (such as video, image, and audio) (for all HTML elements, but common in media elements such as <audio>, <embed>, , <object>, and <video >):

Properties value Description
Onabort Script The script to run on exit.
Oncanplay Script A script that runs when the file is ready to start playing (when the buffer is sufficient to start).
Oncanplaythrough Script A script that runs when the media is able to play to the end without having to stop because of buffering.
Ondurationchange Script A script that runs when the medium length changes.
Onemptied Script A script that runs when a failure occurs and the file is suddenly unavailable (such as when the connection is accidentally disconnected).
onended Script A script that runs when the media has reached the end (a message similar to "thank-you-watch" can be sent).
OnError Script The script that is run when an error occurs during file load.
Onloadeddata Script The script that runs when the media data is loaded.
Onloadedmetadata Script Scripts that run when metadata (such as resolution and duration) is loaded.
Onloadstart Script A script that runs before the file starts to load and does not actually load any data.
OnPause Script A script that runs when the media is paused by the user or program.
Onplay Script The script that runs when the media is ready to start playback.
Onplaying Script The script that runs when the media has started playing.
OnProgress Script The script that runs when the browser is acquiring media data.
Onratechange Script Scripts that run whenever the playback rate changes (such as when the user switches to slow or fast forward mode).
onReadyStateChange Script Scripts that run whenever the readiness state changes (readiness State monitors the state of the media data).
Onseeked Script The script that runs when the seeking property is set to False (indicating that the location has ended).
Onseeking Script The script that runs when the seeking property is set to True (indicating that positioning is active).
Onstalled Script A script that runs when the browser fails to retrieve media data for whatever reason.
Onsuspend Script A script that runs when the media data is terminated for whatever reason before the medium data is fully loaded.
Ontimeupdate Script A script that runs when the playback position changes, such as when the user is fast-forward to a different location in the media.
Onvolumechange Script A script that runs whenever the volume changes, including setting the volume to mute.
Onwaiting Script Run the script when the media has stopped playing but intends to continue playing (such as when the media pauses to buffer more data)

Learning notes: JavaScript body common events

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.