Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / 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.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

HTML: onseeking="JavaScript code"
JavaScript: media.onseeking = handler;

onseeking is an event handler attribute for seeking. On audio and video elements, the browser dispatches this event when a seek operation starts. This can happen even when seeking to the current playback position without changing it. Using the seek bar or setting currentTime in a script can start a seek operation.

The HTML attribute value is JavaScript code, not an event name or file address. Its corresponding JavaScript property, media.onseeking, accepts a handler function; assigning another function replaces the previous one. To add independent listeners, use addEventListener('seeking', handler).

Distinguish seeking from seeked: the former signals the start of seeking, while the latter signals completion. The media.seeking property describes the operation's state; assigning onseeking alone does not change the playback position.

The example deliberately dispatches a synthetic event without a media file. It checks the attribute's handler wiring, not actual seeking. A page's security policy can block inline scripts and event handlers written directly in HTML.

Examples

<!doctype html>
<meta charset="utf-8">
<title>onseeking test</title>
<video id="media" onseeking="document.getElementById('result').textContent = event.type"></video>
<output id="result">pending</output>
<script>
  const media = document.getElementById('media');
  media.dispatchEvent(new Event('seeking'));
</script>

Result

seeking

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources