从 Javascript 设置 HTML5 缓存清单
我正在服务器端生成缓存清单,并且需要通过查询字符串包含一些信息。
我的问题是,我需要包含的信息只能通过使用 Javascript 来获取。因此需要加载页面,然后进行一些 javascript 处理,最后设置清单 url(并更新缓存)。
所以本质上:
$("html").attr("manifest", "/cache.manifest?varfromjs= + somevar);
但这没有任何作用,我尝试调用 window.applicationCache.update()
,但我收到一条错误消息“INVALID_STATE_ERR: DOM Exception 11”,
这是在最新稳定的 Google Chrome 上,但这似乎
是我的第一个 。使用 HTML5 appcache 的时间,所以我可能错过了一些东西,我应该如何做呢?
I'm generating the cache manifest serverside, and I need to include bits of information through querystrings.
My problem is, that the information I need to include is only obtainable by using Javascript. So the page needs to load, then some javascript processing, and finally setting a manifest url (and update the cache).
So in essence:
$("html").attr("manifest", "/cache.manifest?varfromjs= + somevar);
This does nothing though, and I've tried calling window.applicationCache.update()
, but I get an error stating "INVALID_STATE_ERR: DOM Exception 11".
This is on latest stable Google Chrome. It seems to work in Firefox though.
This is my first time using HTML5 appcache, so I may have missed something. How should I go about doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为可以动态添加缓存清单属性,请尝试在服务器端进行处理。
I don't think cache manifest attribute can be added dynamically, try doing your processing on server side.