Javascript DOM HTML Video src Property get

Introduction

Get the URL of a video:

var x = document.getElementById("myVideo").src;

Click the button to get the URL of the video.

View in separate window

<!DOCTYPE html>
<html>
<body>

<video id="myVideo" width="100" height="100" controls src="video.ogg">
  Your browser does not support the video tag.
</video>//ww  w. ja  v  a  2s.  c  o m


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

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

<script>
function myFunction() {
  var x = document.getElementById("myVideo").src;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related