Javascript examples for DOM HTML Element:Audio
The src property sets or gets the value of the src attribute of an audio, which identifies the location (URL) of the audio file.
Set the src property with the following Values
Value | Description |
---|---|
URL | Sets the URL of the audio file. |
Possible values:
A String, representing the URL of the audio file.
The following code shows how to get the URL of an audio file:
<!DOCTYPE html> <html> <body> <audio id="myAudio" controls src="your.ogg"> </audio>/*from w w w . j av a 2s. c om*/ <button onclick="myFunction()">get the URL of the audio</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myAudio").src; document.getElementById("demo").innerHTML = x; } </script> </body> </html>