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

onkeydown — handling a key press

The onkeydown attribute contains JavaScript code that handles the keydown event. It lets you respond to a key press; the event object provides event data. It is not a Boolean attribute.

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

onkeypress — keypress event handler attribute

The global HTML attribute onkeypress contains JavaScript code that handles the keypress event. The attribute name includes the on prefix; the event name does not.

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

onkeyup — handling key release

The onkeyup attribute contains JavaScript that handles the keyup event after a key is released. It is an HTML global attribute, not a way to detect every change to a field's value.

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

onlanguagechange — handling preferred-language changes

The onlanguagechange attribute on body sets the Window object's handler for languagechange. The event signals a change in the user's preferred languages as understood by the browser, rather than a change to the document's lang attribute.

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

onload — handling the load event

The onload attribute contains JavaScript that handles the load event. On the body element, it concerns page loading and handles the Window object's event rather than an event on body itself.

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

onloadeddata — handling available media data

The onloadeddata attribute runs code for the loadeddata event when data for the current audio or video playback position first becomes available. It does not mean the entire file has downloaded or playback has started.

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

onloadedmetadata — handling media metadata loading

The onloadedmetadata attribute contains JavaScript that handles the loadedmetadata event, usually on audio or video. It signals metadata availability, not completion of the download or readiness for uninterrupted playback.

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

onloadstart — handling the start of media loading

The onloadstart attribute specifies JavaScript that handles the loadstart event. For audio and video elements, this event signals the start of looking for media data, not completion of the download or readiness to play.

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

onmessage — handling window messages

The onmessage attribute on body sets the Window object's message event handler. It receives messages sent through postMessage, among other uses; check the sender and payload before using received data.

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

onmessageerror — handling message deserialization failure

The onmessageerror attribute on body sets the Window object's messageerror handler. The event signals failure to deserialize an incoming message, rather than an arbitrary communication error.

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

onmousedown — mouse-button press handler attribute

The onmousedown attribute assigns JavaScript code to an HTML element to handle the mousedown event. It responds to a mouse-button press rather than waiting for a completed click.

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

onmouseenter — handling mouse pointer entry

The global HTML attribute onmouseenter specifies JavaScript to run for the mouseenter event when the mouse pointer enters an element.

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

onmouseleave — handling the mouse leaving an element

The global HTML onmouseleave attribute contains JavaScript that handles the mouseleave event. It lets an element respond when the mouse pointer leaves the element and its descendants.

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

onmousemove — handling mouse movement

The global HTML attribute onmousemove contains JavaScript that handles the mousemove event. The example dispatches it programmatically so the result does not depend on mouse movement.

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

onmouseout — handling a mouse leaving an element

The global onmouseout attribute contains JavaScript code that handles the mouseout event. Use it to respond when the mouse pointer leaves an element.

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

onmouseover — handling pointer entry

The onmouseover attribute contains JavaScript that handles the mouseover event. It can react when the pointer enters an element, but it does not replace keyboard support and can also handle events originating from descendants.

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

onmouseup — handling mouse button release

The global HTML attribute onmouseup contains JavaScript code that handles the mouseup event, associated with releasing a mouse button.

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

onoffline — handling the offline transition event

The onoffline attribute on body sets a handler for the Window object's offline event. It lets a page react when the browser reports lost connectivity, but does not check whether a particular server is reachable.

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

ononline — handling the online event

The ononline attribute on body specifies JavaScript that handles the Window object's online event. It signals a change in the browser's assessment of network availability, but does not confirm that a particular server is reachable.

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

onpagehide — handling page departure

The onpagehide attribute on body registers a handler for the Window object's pagehide event. In a browser-generated event, event.persisted set to true indicates an intent to retain the document for possible reuse, not that it is actually retained.

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

onpagereveal — handling page reveal

The onpagereveal attribute on body sets the handler for the Window object's pagereveal event. The event occurs when the document begins rendering after initialization or reactivation.

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

onpageshow — handling page display

The onpageshow attribute on body assigns JavaScript code to the Window object's pageshow event. It handles both showing a newly loaded document and showing a preserved document again during history navigation.

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

onpageswap — handling an outgoing document during navigation

The onpageswap attribute on body sets the Window handler for the pageswap event. This event concerns the outgoing document during navigation; it is not a notification that a new page has appeared.

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

onpaste — paste event handler

The onpaste attribute assigns JavaScript code to handle the paste event. It is available on all HTML elements, but adding it does not make an element editable.

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