CKTIS / HTML
onprogress — handling download progress events
The onprogress attribute contains JavaScript that handles the progress event. For audio and video elements, it concerns media data downloading, not the passage of playback time.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
onprogress="JavaScript statements"
element.onprogress = handler;
element.addEventListener("progress", handler);onprogress is an event handler attribute for progress. It is available on all HTML elements, but its presence alone does not initiate downloading or generate events. The corresponding JavaScript property is also available on Document and Window objects.
For audio and video, progress reports media data downloading. It does not mean playback progress or automatically provide a percentage of downloaded bytes. The media event uses the Event interface, not ProgressEvent; do not assume that loaded and total are available.
The attribute value is JavaScript code, where event refers to the event. Alternatively, assign a function to element.onprogress or use element.addEventListener("progress", handler). Assigning the property replaces the previous handler for that mechanism; addEventListener() permits independent listeners.
The example explicitly dispatches a synthetic progress event, so its result does not depend on the network. It tests attribute handling, not actual download progress. Content Security Policy can block inline event handlers and inline scripts.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>onprogress demo</title>
<body>
<audio id="media" onprogress="document.getElementById('result').textContent = event.type"></audio>
<p id="result">waiting</p>
<script>
document.getElementById('media').dispatchEvent(new Event('progress'));
</script>
</body>
</html>Result
progress
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.