有没有一种方法可以使用javascript将文件添加到HTML5应用程序缓存中?
有没有办法使用JavaScript将文件动态注入applicationCache?我已经看到了一些对有没有一种方法可以使用javascript将文件添加到HTML5应用程序缓存中?,javascript,html,application-cache,Javascript,Html,Application Cache,有没有办法使用JavaScript将文件动态注入applicationCache?我已经看到了一些对applicationCache.add()函数的引用,但是我找不到任何关于它的文档,在我使用Chrome进行测试时,窗口.applicationCache对象上也没有 我有一个正在开发的web应用程序,它基于一个需要将文件注入applicationCache的决策。不幸的是,这个应用程序没有传统的服务器端组件(它基本上是静态文件和与数据源通信的JS),所以我不能仅仅使用PHP之类的东西创建动态清
applicationCache.add()
函数的引用,但是我找不到任何关于它的文档,在我使用Chrome进行测试时,窗口.applicationCache
对象上也没有
我有一个正在开发的web应用程序,它基于一个需要将文件注入applicationCache的决策。不幸的是,这个应用程序没有传统的服务器端组件(它基本上是静态文件和与数据源通信的JS),所以我不能仅仅使用PHP之类的东西创建动态清单文件
有没有办法做到这一点
谢谢 如何阅读下面的内容,不存在
applicationCache.add()
函数,您只能更新清单,因此使缓存无效
您可以使用
localStorage
来存储文件内容,然后使用数据URI将其作为资源使用。您听到的add()
方法根本不是HTML5脱机应用程序规范的一部分。它似乎是Firefox中Chrome引擎使用的一种浏览器。
[Exposed=Window,SharedWorker]
interface ApplicationCache : EventTarget {
// update status
const unsigned short UNCACHED = 0;
const unsigned short IDLE = 1;
const unsigned short CHECKING = 2;
const unsigned short DOWNLOADING = 3;
const unsigned short UPDATEREADY = 4;
const unsigned short OBSOLETE = 5;
readonly attribute unsigned short status;
// updates
void update();
void abort();
void swapCache();
// events
attribute EventHandler onchecking;
attribute EventHandler onerror;
attribute EventHandler onnoupdate;
attribute EventHandler ondownloading;
attribute EventHandler onprogress;
attribute EventHandler onupdateready;
attribute EventHandler oncached;
attribute EventHandler onobsolete;
};