Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Audio currentSrc attribute

Audio currentSrc attribute

Audio Object Reference Audio object

Example

Get the URL of the current audio:

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

x

The output is:

http://www.w3cschool.cc/try/demo_source/horse.ogg

Try it »


Definition and Usage

The currentSrc attribute returns the URL of the current audio.

If no audio is set, an empty string is returned.

Note: This attribute is read-only.

Tip: Use src Attribute: sets the URL of the audio file.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the currentSrc attribute.

Note: Internet Explorer 8 and earlier IE versions do not support this attribute.


Syntax

audioObject

.currentSrc

Technical Details

Return Value: String representing the URL of the current audio. Returns the actual URL, including the protocol (e.g. http://). If no audio is set, an empty value is returned.

Audio Object Reference Audio object