3

我正在尝试为具有 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 的开发者工具中看到了正确的结果。我得到“应用程序缓存缓存事件”。它只是不能离线工作。我真的被这里难住了...

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

谢谢...

4

1 回答 1

0

您从 Chrome 发布的消息是从 localhost 提供页面时的消息。

检查它是否使用服务器而不是本地主机在 Chrome 上运行。

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

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

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

于 2011-08-24T14:08:20.297 回答