HTML5 AppCache 刷新 - 准确检测正在下载的文件
我通过注册事件来监视我的 HTML5 AppCache 事件,如下所示:
var appCacheEvents = ["checking", "error", "noupdate", "downloading", "progress", "updateready", "cached", "obsolete"];
for (var i = 0; i < appCacheEvents.length; i++) {
applicationCache.addEventListener(appCacheEvents[i], function (evt) {
// Code here to tell me the filename being downloaded???????
});
}
我对下载事件特别感兴趣。传递到函数中的 evt 对象似乎没有任何有关正在下载的文件的信息是否有办法检测正在下载的资源的名称?谢谢。
I am monitoring my HTML5 AppCache events by registering the events as follows:
var appCacheEvents = ["checking", "error", "noupdate", "downloading", "progress", "updateready", "cached", "obsolete"];
for (var i = 0; i < appCacheEvents.length; i++) {
applicationCache.addEventListener(appCacheEvents[i], function (evt) {
// Code here to tell me the filename being downloaded???????
});
}
I am particularly interested in the downloading event. The evt object that is passed into the function does not seem to have any info about the file being downloaded Is there anyway to detect the name of the resource being downloaded? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在寻找“进度”事件,该事件会针对下载的每个文件而触发。
本·纳德尔在他的博客上写了一篇关于此的精彩文章:
http://www.bennadel .com/blog/2029-Using-HTML5-Offline-Application-Cache-Events-In-Javascript.htm
另请参阅:
http://www.slideshare.net /peterlubbers/using-html5-application-cache-to-create-offline-web-applications
You're looking for the "progress" event, which fires for each file that is downloaded.
Ben Nadel wrote a great article about this on his blog:
http://www.bennadel.com/blog/2029-Using-HTML5-Offline-Application-Cache-Events-In-Javascript.htm
See also:
http://www.slideshare.net/peterlubbers/using-html5-application-cache-to-create-offline-web-applications