Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

onprogress

Summary

The user agent is downloading resources listed by the manifest. The event object’s total attribute returns the total number of files to be downloaded. The event object’s loaded attribute returns the number of files processed so far.

Property of apis/appcache/ApplicationCacheapis/appcache/ApplicationCache

Syntax

var result = window.applicationCache.onprogress;
window.applicationCache.onprogress = value;

Return Value

Returns an object of type nullnull

Examples

Registering an progress event handler to keep track of the number of items that need to be fetched and that are already fetched

CACHE MANIFEST
# Example manifest
CACHE:
afile.css
anotherfile.js

// will be called two times in total, because there are two files to fetch (afile.css, anotherfile.js)
window.applicationCache.addEventListener('progress', function (event) {
   console.log('Item', event.loaded, 'of', event.total, 'fetched');
}, false);

Notes

If more than one event is triggered and the progress event is included, the next events may include progress, error, cached, or updateready. Alternatively, you could use an anonymous delegate function such as

object.onprogress = function (e) { … }

where e is the cached event.

Related specifications

W3C ApplicationCache Specification
W3C Editor’s Draft

Attributions

  • Microsoft Developer Network: Article