HTML and CSS Reference
Listing I.13. Adjust the document ready event
Find the complete working example in the index-vtt-4a.html file.
Checking to see if the track is loaded
Text tracks have a ready state similar to other dynamically loadable objects (for example,
XMLHTTP requests). The complete list of values for text tracks is shown in table I.5 .
Table I.5. Track readyState values
The track has not been loaded.
The track is in the process of being loaded.
The track has been loaded.
Attempting to load the track led to an error.
Clearly, all you now need to do is check that the readyState of the track is 2 before you
attempt to access the text property. The next listing shows an updated descriptions
case for the menu-handling function.
Listing I.14. Check the track ready state