Video src Property - Get the URL of a video: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Video

Description

Video src Property - Get the URL of a video:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<video id="myVideo" controls src="your.ogg">
  Your browser does not support the video tag.
</video>/*from  ww w. ja  v  a2  s.c  o m*/

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

<p id="demo"></p>

<script>
var x = document.getElementById("myVideo");

function myFunction() {
    isSupp = x.canPlayType("video/mp4");
    if (isSupp == "") {
        x.src = "your.ogg";
    } else {
        x.src = "your.mp4";
    }
    x.load();

    document.getElementById("demo").innerHTML = x.src;
}
</script>

</body>
</html>

Related Tutorials