Search code examples
cachingpreventdefaultabortdownload

HTML Application Cache abort downloading


is there a way to prevent the download of the application cache, although there is a new one, and only start downloading it, when the user clicks a specific button?

I've tried it already with these codes:

window.applicationCache.addEventListener('ondownloading', function(e) {
  e.abort();
}, false);

window.applicationCache.addEventListener('ondownloading', function(e) {
  e.preventDefault();
}, false);

window.applicationCache.addEventListener('ondownloading', function(e) {
  window.applicationCache.abort();
}, false);

or with "onprogress", "onupdating" etc.

What is going wrong? Is there a way to pretend the "error"-event to abort the caching?

-> I'm using the latest Safari on Windows


Solution

  • Sadly, there's no way to abort or prevent the cache download using Javascript, if a valid manifest file is referenced in the 'html' tag of your document the browser will always try to download it.

    I also noticed you are using an event called "ondownloading", but there's no such event, it's just "downloading", please refer to this for more info: http://developers.whatwg.org/offline.html#offline