0

約 1.5MB になりそうなオフライン Web アプリを作成しています。

ユーザーがアプリをブックマークしたときに、マニフェスト内のすべてのオフライン ファイルがダウンロードされたことを確認する方法はありますか? もっといいのは、iTunes アプリのダウンロードのようなプログレス バーです。

1.5MB はおそらく安全ですが、50MB のオフライン Web アプリを作成し、ユーザーが 3G サービスのない iPad で Wi-Fi を使用しているときにその Web アプリをブックマークしたとします。彼らはそれをブックマークした後、すぐに 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 に答える