0

When using the updateready event of the HTML5 Application Cache API I would like to provide the user with a dynamic count of downloaded resources (like "23 of 400") so he can know how much time he has to wait.

On the console tab of the Chrome browser's Developer tools I can see that information, but how do I access it programmatically using Javascript?

Pedro Almeida
  • 658
  • 1
  • 7
  • 10

1 Answers1

0

The solution is to use the progress event, and the properties lengthComputable, loaded and total:

window.applicationCache.onprogress = function(event) {
    var progress = "";
    if (event && event.lengthComputable) { 
        progress = Math.round(100*event.loaded/event.total) + "%";
    }
    document.getElementById("message_loading").innerHTML=progress;
}
Pedro Almeida
  • 658
  • 1
  • 7
  • 10