Javascript DOM onpause Event via HTML Tag onpause function

Introduction

In JavaScript:

object.onpause = function(){
       myScript};

This example uses the HTML DOM 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 id="myVideo">
  <source src="video.mp4" type="video/mp4">
  <source src="video.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>//from w w  w  . j  a  v  a  2 s  . c o m

<p id="demo"></p>
<script>
document.getElementById("myVideo").onpause = function() {myFunction()};

function myFunction() {
  document.getElementById("demo").innerHTML = "The video was paused";
}
</script>
</body>
</html>
Bubbles: No
Cancelable: No
Event type: Event
Supported HTML tags: <audio> and <video>



PreviousNext

Related