HTML onseeking Event Attribute
Example
When the user starts moving/skipping to a new position in the video, alert some text:
<script>
function myFunction() {
alert('Seek operation
began');
}
</script>
<video onseeking="myFunction()">
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The seeking event occurs when the user starts moving/skipping to a new position in the audio/video.
Tip: The seeking event is the opposite of the seeked event.
Tip: Use the currentTime property of the Audio/Video Object to get the current playback position.
Browser Support
The numbers in the table specify the first browser version that fully supports the event.
Event | |||||
---|---|---|---|---|---|
seeking | Yes | 9.0 | Yes | Yes | Yes |
Syntax
<element onseeking="script">
Attribute Values
Value | Description |
---|---|
script | The script to be run at the beginning of a time-line change |
Technical Details
Supported HTML tags: | <audio> and <video> |
---|
More Examples
Example
This example demonstrates the difference between the seeking event and seeked event:
<video onseeking="myFunction()" onseeked="mySecondFunction()">
Try it Yourself »
Example
Using the currentTime property of the Video Object to display the current playtime position when the user starts to skip to a new position:
// Get the <video> element with id="myVideo"
let vid = document.getElementById("myVideo");
// Attach a seeking event to the <video>, and execute a function if a seek operation begins
vid.addEventListener("seeking", myFunction);
function myFunction() {
// Display the current position of the <video> in a p element with id="demo"
document.getElementById("demo").innerHTML = vid.currentTime;
}
Try it Yourself »
Example
When the user starts moving/skipping to a new position in the audio, alert some text:
<script>
function myFunction() {
alert('Seek operation began');
}
</script>
<audio onseeking="myFunction()">
Try it Yourself »