onseeked

The onseeked event in HTML is triggered when the playback position of a media element has been updated, enabling scripts to take action once the seeking process is finished.

onseeked event

The onseeked event in HTML occurs when the playback position of a media element, like <audio> or <video>, is updated and the seek action is finished. This lets developers run specific actions or scripts after the user jumps to a new position in the media.

Syntax

In HTML

index.html
<element onseeked ="myScript">

In JS

script.js
object.onseeked  = function(){myScript};

In JavaScript, the addEventListener() function is used.

script.js
object.addEventListener("seeked ", myScript);

Example

::event-onseeked ::
index.html
<!DOCTYPE html> 
<html> 
<body> 
<h1>HTML DOM Events</h1>
<h2>The onseeked Event</h2>

<p>Assign an "onseeked" event to a video element.</p>

<p>Move to a new position in the video.</p>

<video controls onseeked="myFunction()">
  <source src="mov_bbb.mp4" type="video/mp4">
  <source src="mov_bbb.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>

<p>Video courtesy of <a href="https://institute.qarpeo.com" target="_blank">Tree</a>.</p>

<p id="demo"></p>

<script>
function myFunction() {
  document.getElementById("demo").innerHTML =  "Seek operation completed!";
}
</script>

</body> 
</html>

Values

Conclusion

The onseeked event allows developers to trigger actions when a user changes the playback position in a media element. It’s useful for updating the UI or executing scripts after the seek operation is complete. This enhances interactivity and control over media playback.