HTML | DOM Track src property
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.
Syntax:
- It is used to return the default property.
trackObject.src
- It is also used to set the default property.
trackObject.src = URL
Value:
- 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.
Example:
<html> <head> <style> body { text-align: center; } h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2> Track src Property </h2> <video width="100" height="100" controls> <track src= kind="subtitles" srclang="en" label="English"> <source id="myTrack" src= type="video/mp4"> </video> <p> Click the button to get the source of the track. </p> <button onclick="myFunction()"> Get URL </button> <p id="gfg"></p> <!-- Script to get the URL property --> <script> function myFunction() { var x = document.getElementById( "myTrack"); document.getElementById( "gfg").innerHTML = myTrack.src; } </script> </body> </html> |
chevron_right
filter_none
Output:
Before clicking on the button:

After clicking on the button:

Supported Browsers:
- Google Chrome
- Internet Explorer 10.0+
- Opera
Recommended Posts:
- HTML | DOM Track srclang property
- HTML | DOM Track readyState property
- HTML | DOM Track label property
- HTML | DOM Track default property
- HTML | DOM Track kind property
- HTML | <track> tag
- HTML | <track> src Attribute
- HTML | DOM Track Object
- HTML | <track> srclang Attribute
- HTML | <track> default Attribute
- HTML | <track> label Attribute
- HTML | <track> kind Attribute
- HTML | DOM dir Property
- HTML | DOM URL Property
- HTML | DOM value Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



