Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML | DOM Track src property

Improve Article
Save Article
  • Last Updated : 22 Aug, 2022
Improve Article
Save Article

The DOM track src property is used to set or return the value of the src attribute which shows the URL of the text track


It is used to return the Track src property.


It is also used to set the Track src property.

trackObject.src = URL


  • URL: It is used to specify the URL of the text track.

Return Value: It returns the URL(including protocol) of the track in the form of string. 



<!DOCTYPE html>
        body {
            text-align: center;
        h1 {
            color: green;
        Track src Property
    <video width="100" height="100" controls>
        <track src=
            kind="subtitles" srclang="en"
        <source id="myTrack" src=
        Click the button to get
        the source of the track.
    <button onclick="myFunction()">
        Get URL
    <p id="gfg"></p>
    <!-- Script to get the Track src property -->
        function myFunction() {
            var x = document.getElementById(
                "gfg").innerHTML = myTrack.src;


 Before clicking on the button:


After clicking on the button: 


Supported Browsers:

  • Google Chrome
  • Internet Explorer 10.0+
  • Opera

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!