Nos bénévoles n'ont pas encore traduit cet article en Français. Inscrivez-vous et aidez-nous à réaliser cette tâche !
Vous pouvez également lire cet article en English (US).

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>).

Constructor

ProgressEvent()
Creates a ProgressEvent event with the given parameters.

Properties

Also inherits properties from its parent Event.

ProgressEvent.lengthComputable Read only
Is a 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
Is an 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
Is an 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.

Methods

Also inherits methods from its parent Event.

ProgressEvent.initProgressEvent()
Initializes a ProgressEvent created using the deprecated Document.createEvent("ProgressEvent") method.

Examples

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()

Specifications

Specification Status Comment
XMLHttpRequest
The definition of 'ProgressEvent' in that specification.
Living Standard  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support1 Yes3.510 Yes Yes
ProgressEvent() constructor Yes ?22 No No No
lengthComputable50 Yes3.5 Yes373.1
loaded No Yes3.5 No No No
total No Yes3.5 No No No
initProgressEvent1 — 17 Yes3.5 — 2210 Yes — 15 Yes —?
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes4 Yes Yes Yes
ProgressEvent() constructor ? No ?22 No No ?
lengthComputable5050 Yes4372 ?
loaded No No Yes4 No No No
total No No Yes4 No No No
initProgressEvent No Yes —? Yes4 — 22 Yes — 15 Yes —? No

See also

  • The Event base interface.

Étiquettes et contributeurs liés au document

Contributeurs à cette page : ddbeck, connorshea, jpmedley, DomenicDenicola, abbycar, Sebastianz, fscholz, teoli
Dernière mise à jour par : ddbeck,