HTML onseeked Attribute

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 3 Examples
Events & Handlers

Introduction

The onseeked attribute is an inline event handler that runs JavaScript when the seeked event fires on an audio or video element. It runs after a seek operation completes — when the user finishes dragging the progress bar or when your code sets currentTime and the new position is ready. Use it to update timestamps, sync captions, log analytics, or refresh a custom seek UI. Read media.currentTime inside your handler. Pair with onseeking for when seeking starts. Prefer addEventListener("seeked", …) in production.

What You’ll Learn

01

Event handler

Inline JS.

02

seeked

Seek done.

03

audio / video

Media only.

04

currentTime

New position.

05

+ onseeking

Seek start.

06

addEventListener

Preferred way.

Purpose of onseeked Attribute

The primary purpose of onseeked is to react when a seek operation finishes — so your page can update a time label, load a new video segment, sync related UI, or run analytics after the user jumps to a different point in the media.

The seeked event fires on the media element after playback position changes and the browser has reached the new position. It is not the same as seeking (seek in progress) or timeupdate (fires continuously during normal playback).

💡
After the scrub, not during

onseeked runs when seeking is complete. Use onseeking if you need to show a loading state while the user is still dragging the seek bar.

📝 Syntax

Set onseeked on <audio> or <video>, or assign element.onseeked in JavaScript:

onseeked.html
<video controls onseeked="seekedHandler()">
  <source src="/video/count.mp4" type="video/mp4">
</video>

<script>
  media.onseeked = seekedHandler;
  media.addEventListener("seeked", seekedHandler);
</script>

Syntax Rules

  • Value is JavaScript executed when the seeked event fires.
  • Valid on <audio> and <video> elements.
  • Fires after seek completes — user scrubbing or currentTime = ….
  • Read element.currentTime for position in seconds.
  • Also assignable as element.onseeked in script.
  • Modern alternative: addEventListener("seeked", handler).
  • Not for non-media elements — use scroll events on containers instead.

💎 Values

The onseeked attribute accepts a string of JavaScript code:

  • onseeked="seekedHandler()" — Call a named function.
  • onseeked="updateTimeLabel()" — Refresh a custom timestamp display.
  • JavaScript: video.onseeked = () => { … } — property assignment.
onseeked-handler.html
function seekedHandler() {
  var t = media.currentTime;
  var mins = Math.floor(t / 60);
  var secs = Math.floor(t % 60).toString().padStart(2, "0");
  timeLabel.textContent = "Now at " + mins + ":" + secs;
}

media.addEventListener("seeked", seekedHandler);

⚡ Quick Reference

Property / APIWhen it runsNotes
seekedSeek operation completesonseeked
seekingSeek operation startsonseeking
currentTimeRead anytimePosition in seconds
durationRead when knownTotal length in seconds
timeupdateDuring playbackFires often — not seek-only

Applicable Elements

ElementSupported?Notes
<video>YesPrimary use — progress bar scrubbing
<audio>YesSame seeked event on audio controls
<source>NoPut handler on parent media element
<iframe>NoEmbedded players are separate documents
<div>, <input>NoNot media elements

onseeked vs onseeking vs ontimeupdate

HandlerWhen it firesTypical use
onseekingSeek starts (scrub begins)Show loading / disable controls
onseekedSeek finishes (new position ready)Update time label, sync UI
ontimeupdateDuring normal playbackProgress bar, elapsed time
onplay / onpausePlayback starts / stopsPlay button state

Examples Gallery

Inline video handler, dynamic assignment, and formatted timestamp after seek with addEventListener.

👀 Live Preview

Drag the audio progress bar — the timestamp updates when seeking finishes:

Scrub the progress bar to seek

Example — onseeked on video

Run a function when the user finishes scrubbing the seek bar:

video-onseeked.html
<video controls onseeked="seekedHandler()">
  <source src="/video/count.mp4" type="video/mp4">
</video>
<p id="status"></p>

<script>
  function seekedHandler() {
    document.getElementById("status").textContent =
      "Seek operation completed!";
  }
</script>
Try It Yourself

How It Works

When the user drags the progress bar (or your code sets currentTime), the browser fires seeked once the new position is ready. The inline attribute runs seekedHandler() at that moment.

Dynamic Values with JavaScript

Assign the handler on a video element at runtime:

dynamic-onseeked.html
<script>
  document.getElementById("myVideo").onseeked = function () {
    log.textContent = "Dynamic seeked handler executed.";
  };
</script>
Try It Yourself

How It Works

Assigning element.onseeked is equivalent to the inline attribute. Use this when you attach the handler after the DOM loads or based on user interaction.

Example — Formatted timestamp after seek

Display minutes and seconds from currentTime when seeking ends:

seeked-time.html
media.addEventListener("seeked", function () {
  var t = this.currentTime;
  var mins = Math.floor(t / 60);
  var secs = Math.floor(t % 60).toString().padStart(2, "0");
  timeLabel.textContent = "Now at " + mins + ":" + secs;
});
Try It Yourself

How It Works

currentTime is in seconds (with decimals). Format it for display after seeked — the value reflects the new playback position.

♿ Accessibility

  • Keyboard seeking — Native controls support keyboard; custom seek UIs need arrow keys and focus styles.
  • Announce position — Use aria-live="polite" when updating a time label after seek.
  • Do not autoplay on seek — Respect user intent; seeking should not unexpectedly start loud playback.
  • Captions sync — After seeked, ensure subtitle tracks match the new position.
  • Visible feedback — Show seek state to all users, not only via console or alerts.

🧠 How onseeked Works

1

User scrubs seek bar

Or code sets currentTime.

Input
2

seeking fires

Seek in progress.

Start
3

seeked fires

onseeked runs.

Event
=

Sync UI

Update time, captions, analytics.

Browser Support

The seeked event and onseeked handler are supported in all modern browsers on HTML5 audio and video elements.

HTML5 Media · Fully supported

Universal onseeked support

All major browsers fire seeked when media seeking completes.

99% Browser support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
Internet Explorer IE 9+ supported
Full support
Opera Fully supported
Full support
onseeked attribute 99% supported

Bottom line: Reliable for seek-complete handling on HTML5 media in all modern browsers.

💡 Best Practices

✅ Do

  • Use onseeked to update UI after scrubbing completes
  • Read currentTime inside the handler for the new position
  • Pair with onseeking for loading states during scrub
  • Use addEventListener("seeked", …) in production
  • Provide visible feedback instead of alert() or console-only logs

❌ Don’t

  • Confuse seeked with timeupdate (continuous playback)
  • Put onseeked on non-media elements
  • Run heavy work on every timeupdate when you only need seek-end logic
  • Assume seeking works before loadedmetadata on all browsers
  • Block native controls without accessible alternatives

Conclusion

The onseeked attribute runs JavaScript when a seek operation completes on audio or video — useful for updating timestamps, syncing captions, and responding after the user scrubs the progress bar.

Read currentTime in your handler, pair with onseeking for seek-start logic, and use addEventListener in production code.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about onseeked

Bookmark these before wiring media seek handlers.

5
Core concepts
02

Seek done

After scrub.

When
🕑 03

currentTime

Read seconds.

API
🔄 04

onseeking

Seek start.

Pair
05

Not timeupdate

Seek vs play.

Gotcha

❓ Frequently Asked Questions

It runs JavaScript when the seeked event fires — after playback position changes and the seek operation completes on audio or video.
When the user finishes dragging the seek bar, or when JavaScript sets currentTime and the browser reaches the new position.
onseeking fires when seeking starts. onseeked fires when seeking finishes and the new position is ready.
Read media.currentTime inside your seeked handler. It returns seconds from the start of the media.
media.addEventListener("seeked", handler) is preferred in production — easier to attach multiple listeners and keep HTML separate from behavior.
Yes in all modern browsers that support HTML5 audio and video seeking.

Build smarter media players

Practice the onseeked attribute with video scrubbing and timestamp labels in the Try It editor.

Try video seek example →

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.

5 people found this page helpful