
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Track Object
The HTML DOM Track Object in HTML represents the <track> element.
Creating a <track> element
var trackObject = document.createElement(“TRACK”)
Here, “trackObject” can have the following properties −
Property |
Description |
---|---|
default |
Itsets/returns the default state of a track |
kind |
Itsets/returns the value of the kind attribute of the track |
label |
Itsets/returns the value of the label attribute of the track |
readyState |
Itreturns the current state of the track resource |
src |
Itsets/returns the value of the src attribute of the track |
srclang |
Itsets/returns the value of the srclang attribute of the track |
track |
Itreturns a TextTrack object representing the track element's texttrack data |
Let us see an example of Track kind property −
Example
<!DOCTYPE html> <html> <head> <title>Track kind</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } </style> </head> <body> <form> <fieldset> <legend>Track-kind</legend> <video id="videoSelect" controls width="250" src="sample.mp4"> <track default kind="subtitles" srclang="es" src="sample-es.srt"/> <track kind="subtitles" srclang="en" src="sample-en.srt"/> </video><br> <input type="button" onclick="getTrackDetails()" value="What is the kind of default track?"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var trackSelect = document.getElementsByTagName("track"); function getTrackDetails() { for(var i=0; i<trackSelect.length; i++) if(trackSelect[i].default) divDisplay.textContent = 'kind of track for video: '+trackSelect[i].kind; } </script> </body> </html>
Output
Before clicking ‘What is the kind of default track?’ button −
After clicking ‘What is the kind of default track?’ button −
Advertisements