HTML5 AppCache refresh - detect exactly which files are being downloaded
I am monitoring my HTML5 AppCache events by registering the events as follows:
var appCacheEvents = ["checking", "error"开发者_JAVA技巧, "noupdate", "downloading", "progress", "updateready", "cached", "obsolete"];
for (var i = 0; i < appCacheEvents.length; i++) {
applicationCache.addEventListener(appCacheEvents[i], function (evt) {
// Code here to tell me the filename being downloaded???????
});
}
I am particularly interested in the downloading event. The evt object that is passed into the function does not seem to have any info about the file being downloaded Is there anyway to detect the name of the resource being downloaded? Thanks.
You're looking for the "progress" event, which fires for each file that is downloaded. Ben Nadel wrote a great article about this on his blog: http://www.bennadel.com/blog/2029-Using-HTML5-Offline-Application-Cache-Events-In-Javascript.htm
See also: http://www.slideshare.net/peterlubbers/using-html5-application-cache-to-create-offline-web-applications
精彩评论