iOS 4.3.4中是否可以使用离线HTML5应用程序?

时间:2011-08-18 18:29:31

标签: ios html5 ios4 ipad-2 manifest.cache

我正在尝试为拥有iOS 4.3.4的iPad 2构建一个支持HTML5的离线应用程序。我按照我在几个网站上看过的说明,甚至能够使用Chrome的开发人员工具验证缓存是否正常工作:

Creating Application Cache with manifest http://localhost/experiments/test.manifest
Application Cache Checking event
Application Cache Downloading event
Application Cache Progress event (0 of 2) http://localhost/experiments/offlineApp.js
Application Cache Progress event (1 of 2) http://localhost/experiments/offlineApp.css
Application Cache Progress event (2 of 2)
Application Cache Cached event

我有一个主屏幕图标以及正在播放的“启动屏幕”图像。我可以将应用程序下载到主屏幕,我看到那里的图标。但是,当我关闭Wi-Fi并尝试打开应用程序时,我发现可怕的“无法打开,因为它没有连接到Internet”警报。

有没有人知道iOS 4.3.4(或操作系统的早期版本)中的某些内容是否发生了变化,这些内容改变了HTML5的这一功能的要求?

谢谢!

修改

我在“localhost”设置之外再次尝试了这个。这是我的HTML:

<!DOCTYPE html>
<html lang="en" manifest="/experiments/cache.manifest">
    <head>
        <meta charset="utf-8"/>
        <title>cache.manifest test</title>
        <link rel="stylesheet" href="cache-manifest-test.css"/>
        <link rel="apple-touch-icon" href="icon.png"/>
    </head>
    <body>
        <h1>cache.manifest</h1>
        <p>Let's see if this thing works...</p>
        <script src="cache-manifest-test.js"></script>
    </body>
</html>

这是我的cache.manifest文件的内容:

CACHE MANIFEST
cache-manifest-test.css
cache-manifest-test.js

我在Chrome的开发者工具中看到了正确的结果。我得到了“应用程序缓存缓存事件”。它只是不能脱机工作。我真的很难过......

有没有人知道任何有完整代码的页面我可以复制到我的服务器并尝试?

...谢谢

1 个答案:

答案 0 :(得分:0)

您从Chrome发布的邮件是从localhost投放网页的时间。

使用服务器而不是localhost检查它是否适用于Chrome。

如果没有,请检查您是否为服务器上的appcache提供了正确的类型(text/cache-manifest)。

如果您在localhost上提供正确的类型但在服务器上没有,则可以解释不同的行为。

另外,我已经读过该文件必须在iPad上命名为“cache.manifest”。如果您已将其命名为其他内容,请尝试使用。