大多數瀏覽器都支持offline app。 我從WHATWG複製示例應用程序,並把它放在一個Web服務器上,但是當我用下面的步驟來測試它不工作:爲什麼離線的web應用程序不起作用?
- 瀏覽隨着Windows Phone 8.1 clock.html(IE 11)
- 頁面看起來不錯,然後再次
- 禁用WiFi和小區數據退出瀏覽器
- 瀏覽到clock.html但得到
Cannot find server or DNS error
我不是在私人瀏覽模式並沒有清除任何瀏覽器緩存。我不知道這是否是特定於Windows Phone的,但稍後會用其他設備進行測試。
clock.appcache
CACHE MANIFEST
CACHE:
clock.html
clock.css
clock.js
clock.html
<!DOCTYPE html>
<html manifest="clock.appcache">
<head>
<title>Clock</title>
<script src="clock.js"></script>
<link rel="stylesheet" href="clock.css">
</head>
<body onload="updateIndicator()" ononline="updateIndicator()" onoffline="updateIndicator()">
<div>The network is: <span id="indicator">(state unknown)</span></div>
<div>The time is: <span id="clock"></span></div>
</body>
</html>
clock.css
.clock { font: 2em sans-serif; }
clock.js
setInterval(function() {
document.getElementById('clock').innerHTML = new Date();
}, 1000);
function updateIndicator() {
document.getElementById('indicator').innerHTML = navigator.onLine ? 'online' : 'offline';
}
脫機時,刷新頁面會再次出現相同的錯誤。任何想法如何解決? –
@RayCheng它可能是緩存標題。 'no-store'會導致問題。其他人喜歡「私人」可能,但我不確定。如果文件需要身份驗證才能訪問或由代碼生成,則有時會自動設置這些頭文件。 – Nicholas