0

我正在製作一個離線的網絡應用程序,看起來它會在1.5MB左右。iOS離線Web應用程序 - 進度條?

反正是有檢查所有的清單我的脫機文件,當用戶書籤我的應用程序被下載?或者更好的是,這樣的進度條是iTunes App下載。

1.5MB可能會是安全的,但可以說我做的離線Web應用程序,這是50MB,並且用戶書籤的Web應用程序,同時通過Wi-Fi在iPad不支持3G服務。他們爲它添加了書籤,然後立即離開了Wi-Fi區域,他們(或者我知道)如果所有文件都被緩存/存儲在本地,他們將如何?

回答

2

使用應用程序緩存事件監聽器

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);