onseekingEvent

事件对象参考手册Event Object

Example

Execute JavaScript when the user starts repositioning the video's playback position:

<video onseeking="myFunction()">

Try it Yourself »

More examples are included at the bottom of this article.


Definition and Usage

The onseeking event triggers when the user starts repositioning the playback position of video/audio (audio/video).

Tip:The opposite of the onseeking event isonseekedevent.

Tip:Use currentTimeto set or return the current playback position of video/audio (audio/video).


Browser Support

The numbers in the table specify the first browser version that fully supports the event.

Event
onseeking Yes 9.0 Yes Yes Yes


Syntax

In HTML:

<element onseeking="myScript">Try it Yourself

In JavaScript:

object.onseeking=function(){myScript};Try it Yourself

In JavaScript, using the addEventListener() method:

object.addEventListener("seeking", myScript);Try it Yourself

Note:Internet Explorer 8 and earlier IE versions do not support theaddEventListener()method.


Technical Details
Bubbles: No
Cancelable: No
Event type: Event
Supported HTML tags: <audio>, <video>


Examples

More Examples

Example

The following example demonstrates the difference between the onseeking event and the onseeked event:

<video onseeking="myFunction()" onseeked="mySecondFunction()">

Try it Yourself »

Example

When the user starts repositioning the playback position, you can use the currentTime property of the Video object to display the current playback position:

// Get the <video> element with id="myVideo"
var x = document.getElementById("myVideo");

// If seeking starts, add the seeking event to the <video> and execute the corresponding function
x.addEventListener("seeking", myFunction);

function myFunction() {
// Display the current playback position of the video in the <p> element with id="demo"
    document.getElementById("demo").innerHTML = x.currentTime;
}

Try it Yourself »

Example

Execute JavaScript when the audio starts repositioning the playback position:

<audio onseeking="myFunction()">

Try it Yourself »


事件对象参考手册Event Object Other Extensions