Video load() Method - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Video

Description

The load() method re-loads the video element to update the video element after changing the source or other settings.

Parameters

None

Return Value

No return value

The following code shows how to Change the video source and re-load the video:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<video id="myVideo" controls autoplay>
  <source id="mp4_src" src="your.mp4" type="video/mp4">
  <source id="ogg_src"  src="your.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>/*from   w  w  w.  j a va 2 s .  com*/

<button onclick="myFunction()">Test</button>

<script>
function myFunction()  {
    document.getElementById("mp4_src").src = "your.mp4";
    document.getElementById("ogg_src").src = "your.ogg";
    document.getElementById("myVideo").load();
}
</script>

</body>
</html>

Related Tutorials