Source src Property
Example
Return the URL of the media file:
var x = document.getElementById("mySource").src;
x The output is:
https://www.runoob.com/try/demo_source/horse.mp3
Try it »
Definition and Usage
The src property sets or returns
The src property specifies the URL of the media file to be played.
Note:
**Note:** Internet Explorer 8 and earlier versions return only the file name (for example, horse.mp3), rather than the full URL (for example, http://www.w3cschool.cc/jsref/horse.mp3).
Browser support





All major browsers support the src property.
Syntax
Return the src attribute:
sourceObject
.src
Set the src attribute:
sourceObject
.src=
URL
Attribute values
| Value | Description |
|---|---|
| URL | Specifies the URL of the media file.
Possible values: |
Technical Details
| Return Value: | A string representing the URL of the media file. Returns the full URL, including the protocol (such as http://). |
|---|
Related Articles
HTML Reference Manual:HTML
The Source object