Javascript DOM oncanplaythrough Event via HTML Tag oncanplaythrough function

Introduction

In JavaScript:

object.oncanplaythrough = function(){
       myScript};

This example uses the HTML DOM to assign an "oncanplaythrough" event to a video element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<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>// w  w w .ja  v  a  2 s  . com

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

function myFunction() {
  document.getElementById("demo").innerHTML = "Can play through video without stopping";
}
</script>

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



PreviousNext

Related