Audio srcProperty
Examples
Get the URL of the audio file:
var x = document.getElementById("myAudio").src;
xThe output is:
http://www.w3cschool.cc/try/demo_source/horse.ogg
Try it Yourself »
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. However, not all major browsers support the defined audio file formats.
Note:Internet Explorer 8 and earlier IE versions do not support the <audio> element.
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: | A string representing the URL of the audio file. Returns the full URL, including the protocol part (such as http://) |
|---|
Related Pages
HTML Reference Manual:HTML <audio> src Attribute.
Audio Object Other Extensions