THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Audio src Property

Audio Object Reference Audio Object

Example

Get the URL of an audio file:

var x = document.getElementById("myAudio").src;

The result of x will be:

http://www.w3schools.com/jsref/horse.ogg
Try it yourself »

Definition and Usage

The src property sets or returns the value of the src attribute of an audio.

The src attribute specifies the location (URL) of the audio file.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The src property is supported in all major browsers. However, the file format defined may not be supported in all browsers.

Note: Internet Explorer 8 and earlier versions, do not support the <audio> element.


Syntax

Return the src property:

audioObject.src

Set the src property:

audioObject.src=URL

Property Values

Value Description
URL Specifies the URL of the audio file.

Possible values:
  • An absolute URL - points to another web site (like src="http://www.example.com/movie.ogg")
  • A relative URL - points to a file within a web site (like src="movie.ogg")

Technical Details

Return Value: A String, representing the URL of the audio file. Returns the entire URL, including the protocol (like http://)

Related Pages

HTML reference: HTML <audio> src attribute


Audio Object Reference Audio Object