The ProgressEvent interface represents events measuring progress of an underlying process, like an HTTP request (for an XMLHttpRequest, or the loading of the underlying resource of an <img>, <audio>, <video>, <style> or <link>).
ProgressEvent()ProgressEvent event with the given parameters.Also inherits properties from its parent Event.
ProgressEvent.lengthComputable Read only
Boolean flag indicating if the total work to be done, and the amount of work already done, by the underlying process is calculable. In other words, it tells if the progress is measurable or not.ProgressEvent.loaded Read only
unsigned long long representing the amount of work already performed by the underlying process. The ratio of work done can be calculated with the property and ProgressEvent.total. When downloading a resource using HTTP, this only represent the part of the content itself, not headers and other overhead.ProgressEvent.total Read only
unsigned long long representing the total amount of work that the underlying process is in the progress of performing. When downloading a resource using HTTP, this only represent the content itself, not headers and other overhead.Also inherits methods from its parent Event.
ProgressEvent.initProgressEvent()
ProgressEvent created using the deprecated Document.createEvent("ProgressEvent") method.The following example adds a ProgressEvent to a new XMLHTTPRequest and uses it to display the status of the request.
var progressBar = document.getElementById("p"),
client = new XMLHttpRequest()
client.open("GET", "magical-unicorns")
client.onprogress = function(pe) {
if(pe.lengthComputable) {
progressBar.max = pe.total
progressBar.value = pe.loaded
}
}
client.onloadend = function(pe) {
progressBar.value = pe.loaded
}
client.send() | Specification | Status | Comment |
|---|---|---|
| XMLHttpRequest The definition of 'ProgressEvent' in that specification. | Living Standard |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | 1 | Yes | 3.5 | 10 | Yes | Yes |
ProgressEvent() constructor |
Yes | ? | 22 | No | No | No |
lengthComputable |
50 | Yes | 3.5 | Yes | 37 | 3.1 |
loaded |
No | Yes | 3.5 | No | No | No |
total |
No | Yes | 3.5 | No | No | No |
initProgressEvent
|
1 — 17 | Yes | 3.5 — 22 | 10 | ? — 15 | ? — ? |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | Yes | Yes | Yes | 4 | Yes | Yes | Yes |
ProgressEvent() constructor |
? | No | ? | 22 | No | No | ? |
lengthComputable |
50 | 50 | Yes | 4 | 37 | 2 | ? |
loaded |
No | No | Yes | 4 | No | No | No |
total |
No | No | Yes | 4 | No | No | No |
initProgressEvent
|
No | ? — ? | Yes | 4 — 22 | ? — 15 | ? — ? | No |
Event base interface.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ProgressEvent