Scenario
An episode page keeps its transcript available on demand. The native disclosure works without JavaScript; JavaScript only adds media sync and cue seeking while open.
Try it
- Open the transcript with Enter or Space on its summary.
- Play the audio or activate a timestamp to seek to that point.
- Close the disclosure, then open it again to reinitialize the transcript.
Example
Read the transcript
Transcript — Local narration
Developer notes
Keep a reference to the returned instance. On close, call destroy();
it removes media, cue, document, and generated-status listeners and markup. On the
next open, call init() to bind the visible transcript again.
let transcript = null;
function updateTranscript() {
if (disclosure.open) {
if (transcript) transcript.init();
else transcript = createA11yTranscript(root);
return;
}
transcript?.destroy();
}
disclosure.addEventListener("toggle", updateTranscript);
updateTranscript();
Accessibility notes
<details>and<summary>provide the disclosure control and keyboard behavior.- The transcript remains readable when JavaScript is unavailable: open the disclosure normally.
- Closing it removes the enhancement only; it does not stop or alter the native audio player.
- Automatic cue changes are not announced. Manual cue activation uses the component’s polite status message while the disclosure is open.