Audio src attribute
Example
Get the URL of the audio file:
var x = document.getElementById("myAudio").src;
x
The output is:
http://www.w3cschool.cc/try/demo_source/horse.ogg
Try it »
Definition and Usage
The src attribute sets or returns the current source of the audio.
The src attribute specifies the location (URL) of the audio file.
Browser support





All major browsers support the src attribute. But not all major browsers support the defined audio file formats.
Note: Internet Explorer 8 and earlier IE versions are not supported.
Syntax
Return the src attribute:
audioObject
.src
Set the src attribute:
audioObject
.src=
URL
Attribute values
| Value | Description |
|---|---|
| URL |
Specifies the URL of the audio source. Possible values: |
Technical Details
| Return Value: | String representing the URL of the audio file. Returns the actual URL, including the protocol part (e.g. http://) |
|---|
Related pages
HTML Reference Manual: HTML
Audio object