View video tutorial

HTML onseeked Attribute

HTML

The HTML onseeked attribute is an event handler used to specify a script that will run when the user finishes moving or skipping to a new position in an <audio> or <video> element.

Definition and Usage


➔ When a "seek" operation is completed, the media element's seeking property changes from true to false.

➔ onseeked is the counterpart of the onseeking attribute which is triggered when the user initiates the skipping process.

Syntax
//In HTML
<video controls onseeked="myFunction()" id="sample">
        <source src="myvideo.mp4" type="video/mp4">
</video>
//In javascript
document.getElementById("sample").onseeked=function() {myFunction();};
//OR
document.getElementById("sample").addEventListener("seeked", myFunction);
//OR 
document.getElementById("sample").addEventListener("seeked", (event) => {
    myFunction();
 });

Example
<html>
<head>
    <title>HTML onseeked attribute example</title>
</head>
<body>
    <h3>HTML onseeked attribute example</h3>
    <p>Set the src correctly and skip playback forward or backward by clicking on the progress bar to trigger the event.</p>
    <!-- "https://mdn.github.io/learning-area/html/multimedia-and-embedding/video-and-audio-content/rabbit320.mp4" -->
    <video controls onseeked="myFunction()" id="sample">
        <source src="myvideo.mp4" type="video/mp4">
        This browser does not support the video tag.
    </video>
    <script>
        //In javascript
        //document.getElementById("sample").onseeked=function() {myFunction();};
        //OR
        //document.getElementById("sample").addEventListener("seeked", myFunction);
        function myFunction() {
            alert("The video playback seeking has finished to a new position.");
        }
    </script>
</body>
</html>

Applies to

This attribute can be used on the following element.

Attribute Element
onseeked <audio>, <video>