Javascript DOM oncanplay Event via HTML Tag oncanplay attribute

Introduction

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

View in separate window

<!DOCTYPE html>
<html>
<body>
<video controls oncanplay="myFunction()">
  <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  .  j  ava2 s  .  co  m

<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Can start playing video";
}
</script>

</body>
</html>
Bubbles: No
Cancelable: No
Event type: Event
Supported HTML tags: <audio> and <video>
DOM Version: Level 3 Events



PreviousNext

Related