【发布时间】:2014-07-04 14:09:55
【问题描述】:
看起来大多数浏览器都支持offline app。 我从WHATWG 复制了示例应用程序并将其放在网络服务器上,但是当我使用以下步骤进行测试时它不起作用:
- 使用 windows phone 8.1 (IE 11) 浏览至 clock.html
- 页面看起来不错,然后退出浏览器
- 禁用 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>
时钟.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';
}
【问题讨论】:
标签: html html5-appcache cache-manifest