Javascript examples for DOM HTML Element:Source
The Source object represents an HTML <source> element.
You can access a <source> element by using getElementById():
<!DOCTYPE html> <html> <body> <audio controls> <source id="mySource" src="your.mp3" type="audio/mpeg"> <source src="your.ogg" type="audio/ogg"> Your browser does not support the audio element. </audio>//from w w w . ja va 2 s . com <button onclick="myFunction()">get the URL of the media file</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("mySource").src; document.getElementById("demo").innerHTML = x; } </script> </body> </html>