Javascript DOM onpause Event

Introduction

Execute a JavaScript when a video has been paused:

This example demonstrates how to assign an "onpause" event to a video element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<p>Play and pause the video.</p>

<video controls onpause="myFunction()">
  <source src="video.mp4" type="video/mp4">
  <source src="video.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>/*from w  w  w.j  a  va  2  s  .  co  m*/
<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "The video was paused.";
}
</script>

</body>
</html>

The onpause event occurs when the audio/video is paused either by the user or programmatically.

The onplay event occurs when the audio/video has started to play.

Bubbles: No
Cancelable: No
Event type: Event
Supported HTML tags: <audio> and <video>



PreviousNext

Related