👀 Live Preview
Drag the audio progress bar — the timestamp updates when seeking finishes:
Scrub the progress bar to seek

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.
Inline JS.
Seek done.
Media only.
New position.
Seek start.
Preferred way.
onseeked AttributeThe 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).
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.
Set onseeked on <audio> or <video>, or assign element.onseeked in JavaScript:
<video controls onseeked="seekedHandler()">
<source src="/video/count.mp4" type="video/mp4">
</video>
<script>
media.onseeked = seekedHandler;
media.addEventListener("seeked", seekedHandler);
</script>seeked event fires.<audio> and <video> elements.currentTime = ….element.currentTime for position in seconds.element.onseeked in script.addEventListener("seeked", handler).The onseeked attribute accepts a string of JavaScript code:
onseeked="seekedHandler()" — Call a named function.onseeked="updateTimeLabel()" — Refresh a custom timestamp display.video.onseeked = () => { … } — property assignment.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);| Property / API | When it runs | Notes |
|---|---|---|
seeked | Seek operation completes | onseeked |
seeking | Seek operation starts | onseeking |
currentTime | Read anytime | Position in seconds |
duration | Read when known | Total length in seconds |
timeupdate | During playback | Fires often — not seek-only |
| Element | Supported? | Notes |
|---|---|---|
<video> | Yes | Primary use — progress bar scrubbing |
<audio> | Yes | Same seeked event on audio controls |
<source> | No | Put handler on parent media element |
<iframe> | No | Embedded players are separate documents |
<div>, <input> | No | Not media elements |
onseeked vs onseeking vs ontimeupdate| Handler | When it fires | Typical use |
|---|---|---|
onseeking | Seek starts (scrub begins) | Show loading / disable controls |
onseeked | Seek finishes (new position ready) | Update time label, sync UI |
ontimeupdate | During normal playback | Progress bar, elapsed time |
onplay / onpause | Playback starts / stops | Play button state |
Inline video handler, dynamic assignment, and formatted timestamp after seek with addEventListener.
Drag the audio progress bar — the timestamp updates when seeking finishes:
Scrub the progress bar to seek
Run a function when the user finishes scrubbing the seek bar:
<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>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.
Assign the handler on a video element at runtime:
<script>
document.getElementById("myVideo").onseeked = function () {
log.textContent = "Dynamic seeked handler executed.";
};
</script>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.
Display minutes and seconds from currentTime when seeking ends:
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;
});currentTime is in seconds (with decimals). Format it for display after seeked — the value reflects the new playback position.
aria-live="polite" when updating a time label after seek.seeked, ensure subtitle tracks match the new position.Or code sets currentTime.
Seek in progress.
onseeked runs.
Update time, captions, analytics.
The seeked event and onseeked handler are supported in all modern browsers on HTML5 audio and video elements.
onseeked supportAll major browsers fire seeked when media seeking completes.
Bottom line: Reliable for seek-complete handling on HTML5 media in all modern browsers.
onseeked to update UI after scrubbing completescurrentTime inside the handler for the new positiononseeking for loading states during scrubaddEventListener("seeked", …) in productionalert() or console-only logsseeked with timeupdate (continuous playback)onseeked on non-media elementstimeupdate when you only need seek-end logicloadedmetadata on all browsersThe 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.
onseekedBookmark these before wiring media seek handlers.
audio / video.
ScopeAfter scrub.
WhenRead seconds.
APISeek start.
PairSeek vs play.
Gotchaseeked event fires — after playback position changes and the seek operation completes on audio or video.currentTime and the browser reaches the new position.onseeking fires when seeking starts. onseeked fires when seeking finishes and the new position is ready.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.Practice the onseeked attribute with video scrubbing and timestamp labels in the Try It editor.
5 people found this page helpful