Get the URL of the current video:
var x = document.getElementById("myVideo").currentSrc;
Click the button to get the URL of the current video.
<!DOCTYPE html> <html> <body> <video id="myVideo" width="100" height="100" controls> <source src="video.mp4" type="video/mp4"> <source src="video.ogg" type="video/ogg"> Your browser does not support the video tag. </video>//w w w . j a va2s .co m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myVideo").currentSrc; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The currentSrc
property returns the URL of the current video.
If no video is set, an empty string is returned.
This property is read-only.
Use the src property to set the URL of a video file.
The currentSrc
property returns a String representing the URL of the current video.
If no video is set, an empty string is returned