浏览器下载完成事件 [英] Browser download complete event
问题描述
我们一直在寻找一个答案,但还没有找到解决方案。
We've been looking for a while for an answer to this, but haven't found a solution.
我们有一个Web服务器,允许用户下载文件(pdf),它们是从servlet动态生成和提供的。我们想知道什么时候下载完成(以及如何成功,失败了,用户是否取消了?)。
We have a web server, which allows the user to download files (pdfs), which are dynamically-generated and served from servlets. We'd like to know when a download has completed (and how: was it successful, did it fail, did the user cancel?).
有没有办法知道这个没有用户输入?这些文件相对较小,因此不需要进度条功能,但是我们需要某种终止钩,当下载完成后会报告回来。这可能吗?
Is there a way to know this without user input? These files are relatively small so no progress-bar functionality is needed, but we need some sort of "end-hook" which reports back when the download has finished. Is this possible?
浏览器端可以检测到最终的下载并通过ajax报告回服务器的功能?
[edit] What capability would there be on the browser-side that can detect end-of-download and report back to the server via ajax?
推荐答案
除非你收到网络错误,否则你不知道。唯一的方法是让浏览器向服务器发送第二个事件(使用AJAX)来确认下载是否已成功完成。
Unless you get a network error, you cannot know. The only way is to have the browser to send a second event to the server (using AJAX) to acknowledge the download was completed successfully.
这篇关于浏览器下载完成事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!