Javascript examples for DOM HTML Element:Video
The src property sets or gets the src attribute of a video, which sets the location (URL) of the video file.
Set the src property with the following Values
Value | Description |
---|---|
URL | Sets the URL of the video file. |
A String, representing the URL of the video file.
The following code shows how to change the URL of a video:
<!DOCTYPE html> <html> <body> <video id="myVideo" controls src="your.ogg"> Your browser does not support the video tag. </video>//from www . j a va 2 s . c om <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 = "changed"; } </script> </body> </html>