HTML5 AppCache 刷新 - 准确检测正在下载的文件

发布于 2024-11-07 01:33:37 字数 461 浏览 2 评论 0原文

我通过注册事件来监视我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

守不住的情 2024-11-14 01:33:37

您正在寻找“进度”事件,该事件会针对下载的每个文件而触发。
本·纳德尔在他的博客上写了一篇关于此的精彩文章:
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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文