Track src Attribute

Definition and Usage

src Sets or returns the value of the track's src attribute.

The HTML src attribute specifies the URL of the track file.

See also:

HTML Reference Manual:HTML <track> src Attribute

Example

Example 1

Get the URL of the track file:

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

The result of x may be:

https://www.codew3c.com/jsref/subtitles_en.vtt

Example 2

Change the URL of the track file:

document.getElementById("myTrack").src = "subtitles_no.vtt";

Syntax

Return the src attribute:

trackObject.src

Set src attribute:

trackObject.src = URL

Attribute Value

Value Description
URL Specifies the URL of the track file.

Technical Details

Return Value: A string value representing the URL of the track file. Returns the entire URL, including the protocol (such as http://).

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supported 10.0 Not Supported Not Supported Supported