0

我正在制作一个看起来大约 1.5MB 的离线网络应用程序。

当用户为我的应用添加书签时,是否有办法检查清单中的所有离线文件是否已下载?或者更好的是,进度条就像 iTunes 应用程序下载一样。

1.5MB 可能是安全的,但假设我制作了一个 50MB 的离线网络应用程序,并且用户在没有 3G 服务的 iPad 上使用 Wi-Fi 时为网络应用程序添加了书签。他们为它添加了书签,然后立即离开了 Wi-Fi 区域,如果所有文件都在本地缓存/存储,他们(或我知道)怎么办?

4

1 回答 1

2

使用 appCache 事件监听器

function handleCacheEvent(e) {
  // Do your thing
}

function handleCacheError(e) {
  alert('Error: Cache failed to update!');
};

// Fired after the first cache of the manifest.
appCache.addEventListener('cached', handleCacheEvent, false);

// Checking for an update. Always the first event fired in the sequence.
appCache.addEventListener('checking', handleCacheEvent, false);

// An update was found. The browser is fetching resources.
appCache.addEventListener('downloading', handleCacheEvent, false);

// The manifest returns 404 or 410, the download failed,
// or the manifest changed while the download was in progress.
appCache.addEventListener('error', handleCacheError, false);

// Fired after the first download of the manifest.
appCache.addEventListener('noupdate', handleCacheEvent, false);

// Fired if the manifest file returns a 404 or 410.
// This results in the application cache being deleted.
appCache.addEventListener('obsolete', handleCacheEvent, false);

// Fired for each resource listed in the manifest as it is being fetched.
appCache.addEventListener('progress', handleCacheEvent, false);

// Fired when the manifest resources have been newly redownloaded.
appCache.addEventListener('updateready', handleCacheEvent, false);
于 2013-08-24T22:55:54.180 回答