onseeking event

Definition and Usage

An onseeking event occurs when the user starts to move/jump to a new position in the audio/video.

Tip:onseeking event with onseeked EventConversely.

Tip:Please use the audio/video object's currentTime PropertyGet the current playback position.

Example

Execute JavaScript when the user starts to move/jump to a new position in the video:

<video onseeking="myFunction()">

Try It Yourself

More TIY examples are below the page.

Syntax

In HTML:

<element onseeking="myScript">

Try It Yourself

In JavaScript:

object.onseeking = function(){myScript};

Try It Yourself

In JavaScript, use the addEventListener() method:

object.addEventListener("seeking", myScript);

Try It Yourself

Note:Internet Explorer 8 or earlier versions do not support addEventListener() method.

Technical details

Bubble: Not supported
Cancelable: Not supported
Event type: Event
Supported HTML tags: <audio> and <video>
DOM version: Level 3 Events

Browser support

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

Event Chrome IE Firefox Safari Opera
onseeking Support 9.0 Support Support Support

More examples

Example

This 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 to jump to a new position, use the Video object's currentTime property to display the current playtime position:

// Get the <video> element with id="myVideo"
var x = document.getElementById("myVideo");
// Attach a seeking event to the <video> and execute a function when the seek operation starts
x.addEventListener("seeking", myFunction); 
function myFunction() {
  // Display the current 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 user starts moving/jumping to a new position in the audio:

<audio onseeking="myFunction()">

Try It Yourself