HTML onseeked Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The onseeked attribute is an event-handler attribute for <audio> and <video>. It runs JavaScript when the seeked event fires — a seek finished: the playback position changed, and the Boolean seeking property became false.

The event is not cancelable and does not bubble. Scrub the timeline, jump with currentTime, or use chapter buttons — when the media finds the new position, seeked fires. Pair with onseeking (seek started) and contrast with ontimeupdate (ongoing time changes).

Baseline · Widely available.

Not deprecated and not experimental. The seeked event is stable across modern browsers since about July 2015.

Prefer addEventListener in apps.

Inline onseeked is fine for learning. Production code usually uses media.addEventListener("seeked", handler).

HTML Syntax

syntax.html
<video|audio onseeked=" script">

script is JavaScript that runs when seeked fires. Equivalent JS: media.onseeked = handler or media.addEventListener("seeked", handler).

Attribute Values

The attribute value is always a script. Common patterns:

Value / patternDescriptionTry it
scriptAny JavaScript run when a seek completesTry it
onseeked="fn()"Call a named function from the attributeTry it
addEventListener("seeked")Preferred modern listener on audio/videoTry it
With seekingShow start vs finish of a scrubTry it
+ currentTimeRead the new position after seekTry it

Live Preview

Scrub the timeline or jump ahead. Status updates for seeking and seeked.

Media

Sample /video/count.mp4 or /audio/count.mp3. Drag the seek bar or use Jump.

Player

Idle — scrub or jump

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Inline onseeked on Video

Show currentTime when a seek finishes.

HTML
<video id="clip" width="400" height="225" controls onseeked="onSeekDone()">
  <source src="/video/count.mp4" type="video/mp4">
</video>
<p id="status">Scrub the timeline…</p>

<script>
  function onSeekDone() {
    var t = document.getElementById("clip").currentTime.toFixed(1);
    document.getElementById("status").textContent =
      "seeked — now at " + t + "s";
  }
</script>
Try It Yourself

How It Works

  1. Put onseeked on the media element — here <video>.
  2. User scrubs (or script sets currentTime).
  3. Seek completes — seeking becomes false.
  4. Handler reads currentTime — update UI or analytics.

Example 2 — addEventListener on Audio

Preferred script pattern on an audio element.

HTML
<audio id="clip" controls>
  <source src="/audio/count.mp3" type="audio/mpeg">
</audio>
<p id="log">Idle</p>

<script>
  document.getElementById("clip").addEventListener("seeked", function () {
    document.getElementById("log").textContent =
      "seeked at " + this.currentTime.toFixed(1) + "s (seeking=" + this.seeking + ")";
  });
</script>
Try It Yourself

How It Works

  1. Select the audio with getElementById.
  2. Register seeked with addEventListener.
  3. After scrub, seeking should be false.
  4. Log currentTime so the new position is clear.

Example 3 — seeking vs seeked

Show both ends of a seek for loading UI.

HTML
<video id="clip" width="400" height="225" controls>
  <source src="/video/count.mp4" type="video/mp4">
</video>
<p id="state">State: idle</p>

<script>
  var clip = document.getElementById("clip");
  var state = document.getElementById("state");

  clip.addEventListener("seeking", function () {
    state.textContent = "State: seeking…";
  });
  clip.addEventListener("seeked", function () {
    state.textContent = "State: seeked at " + this.currentTime.toFixed(1) + "s";
  });
</script>
Try It Yourself

How It Works

  1. seeking — seek started; show a brief loader if needed.
  2. seeked — seek done; hide loader and read currentTime.
  3. Fast local seeks may flash through seeking quickly — that’s normal.
  4. For ongoing playtime use ontimeupdate, not only seeked.

Edge Cases & Pitfalls

Most confusion is mixing seeked with continuous timeupdate, or expecting a seek before media is ready.

vs seeking

seeking ≠ seeked

seeking means the seek started (seeking === true). seeked means it finished (seeking === false).

timeupdate

Not a progress ticker

timeupdate fires often during playback. Use seeked for “jump finished,” not for every second of play.

ready

Seek before data is ready

Setting currentTime too early may delay or fail until enough media is loaded. Wait for metadata or a usable readyState.

bubble

Does not bubble

Listen on the audio/video element itself. Parent listeners will not see a bubbling seeked.

property

.onseeked = replaces listeners

Assigning the IDL property overwrites a previous assignment. Prefer addEventListener for multiple handlers.

Browser Support

onseeked is an HTML event-handler attribute for media elements in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

onseeked

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support the seeked event on audio and video.

97% Global support (approx.)
Google Chrome 3+
Full support
Mozilla Firefox 3.5+
Full support
Apple Safari 3.1+
Full support
Microsoft Edge 12+
Full support
Opera 10.5+
Full support
Samsung Internet Modern · Full
Full support
Internet Explorer 9+
Supported
onseeked Widely supported

Bottom line: Safe to use for scrub UI. Prefer addEventListener in production, and pair with seeking when you need a loading state during jumps.

Key Takeaways

  • Role: run script when a media seek has completed.
  • Signal: position changed and seeking is now false.
  • Pair with: onseeking for start; ontimeupdate for play progress.
  • Read: currentTime after seeked for the new position.

One line: onseeked means “the jump finished” — read currentTime, and use onseeking if you need a mid-seek loading state.

Frequently Asked Questions

It is an event-handler attribute on audio or video. When a seek finishes — the playback position has moved and the seeking property becomes false — the seeked event fires and the script runs.
The HTML audio and video elements. Put the handler on the media element itself.
onseeking fires when a seek starts (seeking becomes true). onseeked fires when the seek completes (seeking becomes false). Pair them for loading UI during scrubbing.
ontimeupdate fires often while currentTime changes during normal playback. onseeked fires once when a seek operation completes (scrub, jump, or currentTime assignment that seeks).
Both work. For learning, onseeked in HTML is fine. In production code, prefer media.addEventListener("seeked", handler).
No. The seeked event and onseeked handler are standard HTML media features and Baseline widely available since about July 2015.

Next: onseeking

React when a seek operation starts and seeking becomes true.

onseeking tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful