CKTIS / HTML
onwaiting — handling waits for media data
The onwaiting attribute specifies code to run for the waiting event. On audio and video elements, this event signals that playback cannot continue because sufficient data is unavailable. The attribute itself does not start downloading or playback.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
onwaiting="JavaScript statements"
media.onwaiting = (event) => { /* handle waiting */ };onwaiting is the event-handler attribute for waiting. Its HTML value is JavaScript code, not a Boolean value. It is available on all HTML elements, but its typical use is with audio and video elements. Its JavaScript counterpart is the onwaiting property.
The waiting event indicates that playback cannot continue because data needed for the next step is unavailable. It can occur when starting playback or after the buffer runs out. By itself, it does not mean a permanent error or a lost network connection. Do not confuse it with stalled, which concerns data failing to arrive while the browser is trying to fetch it.
A handler can display a waiting indicator; the playing event lets you respond when playback starts or resumes. A natural waiting event does not bubble and is not cancelable, so return false will not resume playback. Assigning a function to media.onwaiting replaces that property's previous handler; addEventListener('waiting', handler) allows independent listeners to be registered.
The example deliberately dispatches a synthetic event so that its result does not depend on a media file or the network. The paragraph should change from idle to waiting. This tests only the handler wiring: it does not cause real buffering or change playback state. A page's security policy may block inline scripts and inline event handlers.
Examples
<!doctype html>
<meta charset="utf-8">
<title>onwaiting demo</title>
<video id="media" onwaiting="document.getElementById('status').textContent = event.type"></video>
<p id="status">idle</p>
<script>
const media = document.getElementById('media');
media.dispatchEvent(new Event('waiting'));
</script>Result
waiting
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.