javascript - 使用 HTML5 缓存时无法加载外部资源

标签 javascript html html5-appcache

我正在尝试让应用缓存工作:

CACHE MANIFEST

/css/style.css
/js/colors.js
/js/dropzone.js
/js/jquery.min.js
/js/script.js

/img/icon_analytics.png
/img/icon_exit.png
/img/icon_expand.png
/img/icon_list.png
/img/icon_lock.png
/img/icon_menu.png
/img/icon_more_content.png
/img/icon_settings.png
/img/icon_settings_black.png
/img/svg_icons/close_fullscreen.svg
/img/svg_icons/go_fullscreen.svg
/img/loader.gif

但这是我在控制台中得到的:

GET https://www.google.com/jsapi net::ERR_FAILED
(index):517 Uncaught ReferenceError: google is not defined
(index):524 GET http://www.google-analytics.com/analytics.js net::ERR_FAILED
0.s3.envato.com/files/115114837/profile.jpg:1 GET https://0.s3.envato.com/files/115114837/profile.jpg net::ERR_FAILED
jquery.min.js:3 GET http://fonts.gstatic.com/s/roboto/v15/mnpfi9pxYH-Go5UiibESIpBw1xU1rKptJj_0jans920.woff2 net::ERR_FAILED

显然,它拒绝加载任何未在 .appcache 文件中指定的资源。我什至尝试只指定图像,它仍然会为样式表和所有 .js 文件抛出错误。

这是怎么回事?

最佳答案

您需要添加 NETWORK 部分,如下所示:

CACHE MANIFEST

CACHE:
/css/style.css
/js/colors.js
/js/dropzone.js
/js/jquery.min.js
/js/script.js

/img/icon_analytics.png
/img/icon_exit.png
/img/icon_expand.png
/img/icon_list.png
/img/icon_lock.png
/img/icon_menu.png
/img/icon_more_content.png
/img/icon_settings.png
/img/icon_settings_black.png
/img/svg_icons/close_fullscreen.svg
/img/svg_icons/go_fullscreen.svg
/img/loader.gif

NETWORK:
*

阅读more在这里。

关于javascript - 使用 HTML5 缓存时无法加载外部资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28918579/

相关文章:

javascript - 同时替换字符串的多个部分

javascript - 缩略图滚动中图像之间/之后的大间隙

javascript - 在 Canvas 中用圆圈连接线

javascript - 带有 setInterval 的 jQuery 插件作用域

html - 使用相同的 CSS 类对两个部分进行不同的样式设置

html - 如何使用省略号删除右侧的多余空间

javascript - 如何在鼠标悬停时覆盖 div/box?

php - AppCache list 错误

html - iOS6 网络应用程序的最大缓存大小是多少?我该如何扩展它?

android - 如何使用 HTML5 Appcache 缓存所有内容?