Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Knowledge base

Knowledge base

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 5788

HTML

onpause — media pause event handler

The onpause attribute contains JavaScript that handles the pause event, usually on an audio or video element. It reacts to playback being paused but does not itself pause playback.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onplay — handling the play event

The onplay attribute contains JavaScript executed for the play event, typically on an audio or video element. This event signals leaving the paused state, not a guarantee that sound or video is already playing.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onplaying — handling readiness to play

The onplaying attribute contains code that handles the playing event, used by audio and video when playback is ready to start or resume after an interruption. It does not start playback and is not equivalent to onplay.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onpopstate — handling changes to the active history entry

The onpopstate attribute on body sets the Window object's popstate event handler. It lets a page respond to session history traversal, such as Back and Forward navigation, and read the destination entry's state.

Intermediate · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onprogress — handling download progress events

The onprogress attribute contains JavaScript that handles the progress event. For audio and video elements, it concerns media data downloading, not the passage of playback time.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onratechange — handling playback-rate changes

The onratechange attribute specifies JavaScript that handles the ratechange event, fired after a media element's playbackRate or defaultPlaybackRate changes.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onrejectionhandled — handling a Promise rejection later

The body attribute onrejectionhandled registers a handler for the Window rejectionhandled event: a previously unhandled Promise rejection has subsequently acquired a handler.

Intermediate · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onreset — handling form resets

The onreset attribute contains JavaScript that handles a form's reset event. The handler runs before default values are restored and can cancel the reset.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onresize — resize event handler attribute

The onresize attribute contains JavaScript that handles a resize event. On the body element, it targets Window rather than changes to the size of the body element itself.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onscroll — handling scrolling events

The onscroll attribute contains JavaScript executed when a scroll event is received. It lets an element react to scrolling, but does not itself create a scrollable area.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onscrollend — handling the end of scrolling

The onscrollend attribute assigns JavaScript code to the scrollend event, which signals that scrolling has finished. Distinguish the attribute name from the event name used with addEventListener().

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onsecuritypolicyviolation — handling CSP violation events

The onsecuritypolicyviolation attribute specifies JavaScript that handles the securitypolicyviolation event associated with a Content Security Policy (CSP) violation. It does not establish a security policy, and CSP can block its inline code.

Intermediate · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onseeked — handling completed media seeking

The onseeked attribute specifies JavaScript to run for the seeked event. On audio and video elements, this event signals that a seek has completed, not that media playback has ended.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onseeking — handle the start of media seeking

`onseeking` specifies code that handles the `seeking` event. The event signals the start of a seek operation in audio or video, even if the playback position stays the same. It does not signal completion.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onselect — handling text selection

The onselect attribute defines JavaScript that runs when a select event occurs, typically when text is selected in an input or textarea control. It does not detect option selection in a select element.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onslotchange — handling the slotchange event

onslotchange specifies a handler for the slotchange event. In Shadow DOM, this event can fire when a slot’s assigned nodes change or when a direct child is added to or removed from a slot with no assigned nodes.

Intermediate · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onstalled — handling stalled media downloads

The onstalled attribute specifies code to run for the stalled event, when the browser is trying to fetch media data but data is not arriving. This concerns downloading, not necessarily an interruption of playback.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onstorage — handling Web Storage changes

The onstorage attribute on body sets the Window handler for the storage event. It reacts to changes to shared localStorage or sessionStorage made in another document, rather than in the document performing the write.

Intermediate · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onsubmit — handling a form submission attempt

The onsubmit attribute specifies JavaScript that handles the submit event. It lets you react to a form submission attempt and cancel the default submission; it does not confirm that data reached the server.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onsuspend — handling suspended media fetching

The onsuspend attribute specifies JavaScript to run for the suspend event. For audio and video, this event means the browser is intentionally not fetching data at present, not that playback has been paused.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

ontimeupdate — handling media time updates

The ontimeupdate attribute contains JavaScript that handles the timeupdate event, used when an audio or video playback position is updated. It can refresh a time indicator but does not provide precise timing.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

ontoggle — handling open-state changes

The ontoggle attribute contains JavaScript that handles the toggle event after an element's open state changes. Relevant elements include details, dialog, and elements acting as popovers. The attribute does not itself open or close an element.

Basic · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onunhandledrejection — unhandled promise rejection

The onunhandledrejection attribute on body registers a handler for the Window object's unhandledrejection event. It exposes the rejection reason of a promise that still lacks rejection handling when notification occurs.

Intermediate · WHATWG HTML Living Standard; index snapshot date recorded separately
HTML

onunload — handling document unloading

The body element's onunload attribute sets a handler for the Window object's unload event, not an event handler targeting the element itself. It is neither a reliable place to save data nor a way to prevent leaving a page.

Intermediate · WHATWG HTML Living Standard; index snapshot date recorded separately