👀 Live Preview
Drag the audio progress bar — status shows “Seeking…” then the new time:
Ready — scrub to seek

The onseeking attribute is an inline event handler that runs JavaScript when the seeking event fires on an audio or video element. It runs when a seek operation starts — as the user begins dragging the progress bar or when your code sets currentTime. Use it to show a loading indicator, disable custom controls, or pause related animations while the browser jumps to a new position. Check media.seeking (true during seek). Pair with onseeked when seeking finishes. Prefer addEventListener("seeking", …) in production.
Inline JS.
Seek starts.
Media only.
Boolean flag.
Seek done.
Preferred way.
onseeking AttributeThe primary purpose of onseeking is to react when a seek operation begins — so your page can show “buffering” feedback, temporarily disable buttons, hide stale captions, or prepare UI before the new playback position is ready.
The seeking event fires on the media element when playback position is about to change. It is the counterpart to seeked, which fires when seeking is complete. Together they cover the full seek lifecycle.
onseeking runs when scrubbing begins. Use onseeked to update the final timestamp or resume UI after the new position loads.
Set onseeking on <audio> or <video>, or assign element.onseeking in JavaScript:
<video controls onseeking="handleSeeking()">
<source src="/video/count.mp4" type="video/mp4">
</video>
<script>
media.onseeking = handleSeeking;
media.addEventListener("seeking", handleSeeking);
</script>seeking event fires.<audio> and <video> elements.currentTime = ….element.seeking — true while seek is in progress.element.onseeking in script.addEventListener("seeking", handler).onseeked for seek-complete logic.The onseeking attribute accepts a string of JavaScript code:
onseeking="handleSeeking()" — Call a named function.onseeking="showSpinner()" — Show loading UI during scrub.video.onseeking = () => { … } — property assignment.function handleSeeking() {
status.textContent = "Seeking…";
status.classList.add("is-seeking");
}
function handleSeeked() {
status.textContent = "Ready at " + formatTime(media.currentTime);
status.classList.remove("is-seeking");
}
media.addEventListener("seeking", handleSeeking);
media.addEventListener("seeked", handleSeeked);| Property / API | When it runs | Notes |
|---|---|---|
seeking | Seek operation starts | onseeking |
seeked | Seek operation completes | onseeked |
media.seeking | Read anytime | true while seeking |
currentTime | Read anytime | Target position (may update) |
timeupdate | During playback | Not seek-specific |
| Element | Supported? | Notes |
|---|---|---|
<video> | Yes | Primary use — progress bar scrubbing |
<audio> | Yes | Same seeking 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 |
onseeking vs onseeked vs ontimeupdate| Handler | When it fires | Typical use |
|---|---|---|
onseeking | Seek starts (scrub begins) | Loading spinner, disable controls |
onseeked | Seek finishes (position ready) | Update time label, sync UI |
ontimeupdate | During normal playback | Progress bar, elapsed time |
onwaiting | Playback stalled (buffering) | Network buffer indicator |
Inline video handler, dynamic assignment, and paired seeking + seeked status labels.
Drag the audio progress bar — status shows “Seeking…” then the new time:
Ready — scrub to seek
Run a function when the user starts scrubbing the seek bar:
<video controls onseeking="handleSeeking()">
<source src="/video/count.mp4" type="video/mp4">
</video>
<p id="status"></p>
<script>
function handleSeeking() {
document.getElementById("status").textContent = "Seeking…";
}
</script>When the user starts moving the progress bar (or your code changes currentTime), the browser fires seeking and runs handleSeeking(). The new position may not be ready yet — that is what onseeked is for.
Assign the handler on a video element at runtime:
<script>
document.getElementById("dynamicVideo").onseeking =
function () {
log.textContent = "Seeking event detected!";
};
</script>Assigning element.onseeking is equivalent to the inline attribute. Use this when you attach the handler after the DOM loads or based on user interaction.
Show loading on seek start and final time on seek complete:
media.addEventListener("seeking", function () {
status.textContent = "Seeking…";
status.setAttribute("aria-busy", "true");
});
media.addEventListener("seeked", function () {
status.textContent = "Now at " + formatTime(this.currentTime);
status.removeAttribute("aria-busy");
});seeking and seeked bookend every seek operation. Use both for polished custom players with clear user feedback.
aria-busy="true" and aria-live="polite" during seeking.seeked syncs the new position.Or code sets currentTime.
onseeking runs.
seeking is true.
Position ready — onseeked.
The seeking event and onseeking handler are supported in all modern browsers on HTML5 audio and video elements.
onseeking supportAll major browsers fire seeking when media seeking begins.
Bottom line: Reliable for seek-start handling on HTML5 media in all modern browsers.
onseeking for loading UI when scrubbing startsonseeked to complete the seek lifecyclemedia.seeking for current seek stateaddEventListener("seeking", …) in productionaria-busy during seek for screen reader usersseeking with seeked (start vs end)onseeking on non-media elementsonseeking — wait for onseekedalert() for seek feedbackseeked fails to fireThe onseeking attribute runs JavaScript when a seek operation starts on audio or video — useful for showing loading states, disabling controls, and preparing UI before the new playback position is ready.
Pair it with onseeked, read media.seeking for state, and use addEventListener in production code.
onseekingBookmark these before wiring seek-start handlers.
Not complete.
Whenaudio / video.
Scopetrue / false.
APISeek end.
PairSeek vs play.
Gotchaseeking event fires — when a seek operation starts on audio or video.currentTime and the browser begins moving to the new position.onseeking fires when seeking starts. onseeked fires when seeking finishes and the new position is ready.media.seeking — it is true while a seek operation is in progress.media.addEventListener("seeking", handler) is preferred in production — easier to attach multiple listeners and pair with seeked.Practice the onseeking attribute with seek-start feedback and paired seeked handlers in the Try It editor.
5 people found this page helpful