The oncuechange attribute is an event-handler attribute for the <track> element. It runs JavaScript when the cuechange event fires — the text track’s currently displaying cues changed (a WebVTT line started or ended).
Put <track> inside <video> or <audio>. Read active lines from event.target.track.activeCues. The same event also fires on the underlying TextTrack object.
Baseline · Widely available.
Not deprecated and not experimental. cuechange on HTMLTrackElement is widely available since about July 2019 (the TextTrack event earlier).
Track must not be disabled.
Cues only activate when the track mode is showing or hidden. Use the default attribute on <track>, or set textTrack.mode in script.
Syntax
HTML Syntax
syntax.html
<track oncuechange="script">
script is JavaScript that runs when active cues change. Equivalent JS: trackEl.oncuechange = handler or trackEl.addEventListener("cuechange", handler).
Values
Attribute Values
The attribute value is always a script. Common patterns:
Set mode = "hidden" so cues still activate without the browser overlay.
Wait for metadata so the TextTrack is ready.
On cuechange, copy activeCues text into your own element.
Use aria-live if screen-reader users should hear caption updates.
Edge Cases & Pitfalls
Most failures are a disabled track, missing VTT, or listening on the wrong object.
mode
Disabled tracks never cuechange
If mode is disabled, cues stay inactive. Use default, or set showing / hidden.
origin
Same-origin VTT (unless CORS)
Track src must match the document origin unless the media element uses a proper crossorigin setup.
vs timeupdate
Not the same as ontimeupdate
timeupdate fires often during playback. Prefer cuechange when you only care about caption line changes.
target
Listen on track or TextTrack
The event fires on both. On the element, use event.target.track.activeCues. On TextTrack, use track.activeCues directly.
empty
Empty activeCues is normal
Between cues (or after the last one), the list can be empty. Clear your custom caption UI in that case.
Compatibility
Browser Support
oncuechange is an HTML event-handler attribute for media text tracks in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
oncuechange
Widely available on HTMLTrackElement since about July 2019. Chrome, Firefox, Safari, and Edge support cuechange for WebVTT tracks on audio and video.
95%Global support (approx.)
Google Chrome23+
Full support
Mozilla Firefox31+
Full support
Apple Safari6+
Full support
Microsoft Edge12+
Full support
Opera15+
Full support
Samsung InternetModern · Full
Full support
Internet Explorer10+
Supported
oncuechangeWidely supported
Bottom line: Safe to use for caption-driven UI. Ensure the track is enabled (default or mode), and prefer addEventListener in production.
Remember
Key Takeaways
Role: run script when a text track’s active cues change.
Element:<track> inside audio/video + WebVTT.
Data: read activeCues for the current caption text.
Enable track:default or mode showing/hidden.
One line:oncuechange updates when caption cues change — enable the track, then read activeCues.
Frequently Asked Questions
It is an event-handler attribute on a track element. When the text track’s currently displaying cues change during media playback, the cuechange event fires and the JavaScript in oncuechange runs.
Primarily the HTML track element (child of audio or video). The same cuechange event also fires on the underlying TextTrack object.
activeCues is a list on TextTrack of the cues that are active at the current media time. In a cuechange handler, read event.target.track.activeCues (on a track element) and use cue.text for the caption line.
The track mode must be showing or hidden — not disabled. Add the default attribute on track, or set textTrack.mode = "hidden" or "showing" in script after the track loads.
ontimeupdate fires often as currentTime advances. oncuechange fires only when the set of active cues changes — better for caption UI updates.
No. The cuechange event is standard and Baseline widely available. Support on HTMLTrackElement has been widely available since about July 2019.