Javascript DOM onloadstart Event via addEventListener() method

Introduction

In JavaScript, using the addEventListener() method:

object.addEventListener("loadstart",
       myScript);

This example uses the addEventListener() method to attach a "loadstart" 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>/*from   w  w  w.  ja v  a  2  s. com*/

<p id="demo"></p>
<script>
document.getElementById("myVideo").addEventListener("loadstart", myFunction);
function myFunction() {
  document.getElementById("demo").innerHTML = "Starting to load video";
}
</script>

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



PreviousNext

Related