Return the URL of a media file:
The result of x will be:
The src property sets or returns the value of the src attribute in a <source> element.
The src attribute specifies the URL of the media file to play.
Note: The <source> element is new in HTML5.
Note: Internet Explorer 8 and earlier versions, only returns the file name(e.g. horse.mp3), instead of the URL (http://www.w3schools.com/jsref/horse.mp3).
The src property is supported in all major browsers.
Return the src property:
Set the src property:
Value | Description |
---|---|
URL | Specifies the URL of the media file. Possible values:
|
Return Value: | A String, representing the URL of the media file. Returns the entire URL, including the protocol (like http://) |
---|
HTML reference: HTML <source> src attribute