The HTML onseeked event
The HTML onseeked attribute runs JavaScript once a seek in <audio> or <video> has landed. In <video onseeked="updateLabel(this)">, the label changes once the jump is complete. By then seeking is false and currentTime holds the new position.
Overview
The HTML onseeked attribute runs code at the end of a seek, once audio or video reaches its target. The seeked event fires after the playback position has changed and the seeking property is false again.
Every completed seek ends with a seeked event, and onseeking marks the start of the same jump.
A burst of seeks can end in one event. When code sets the position twice in a row, Chrome fires seeking for each change but seeked only once, for the final position. Counting seeked events can therefore undercount jumps.
Inside the handler, the new position is settled. That makes seeked the moment to update a time label, sync anything tied to the timeline, or record that a viewer skipped ahead.
Syntax
<video src="clip.mp4" controls onseeked="updateLabel(this)"></video>
Example
<video id="clip" src="https://codeshack.io/web/example.mp4" controls muted width="240" onseeked="landed(this)"></video>
<p>
<button type="button" data-t="5">0:05</button>
<button type="button" data-t="15">0:15</button>
<button type="button" data-t="25">0:25</button>
</p>
<p id="msg" role="status">Pick a chapter or drag the progress bar.</p>
<script>
for (const b of document.querySelectorAll('button[data-t]')) {
b.addEventListener('click', function () {
document.getElementById('clip').currentTime = Number(b.dataset.t);
});
}
function landed(video) {
const s = Math.round(video.currentTime);
document.getElementById('msg').textContent = 'Now at 0:' + String(s).padStart(2, '0');
}
</script>
Best practices
- Update time labels and chapter highlights in onseeked rather than onseeking, because the position is final by then.
- Don't treat seeked as a sign that playback resumed. Seeking doesn't start playback, so a paused video is still paused afterward.
- Give jump buttons visible text such as 0:15, so the target time is clear without a tooltip.
- Check
video.loopor the position before counting a seek as a skip ahead, since a looping video also fires seeked when it wraps back to the start.
Accessibility
Announce where playback landed from onseeked, with a status message such as "Now at 0:15". Make chapter and jump controls real buttons with readable labels, so keyboard and screen reader users can move through the video the same way as mouse users.























