检测何时“文件下载"弹出窗口已关闭 [英] detecting when the "File download" popup is closed

查看:25
本文介绍了检测何时“文件下载"弹出窗口已关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页(用 JSF 制作),其中一些链接允许用户获取 PDF 文件.

当用户点击这样的链接时,会显示一个等待的弹窗(它是一个模态面板)(因为生成的PDF可能会很长),一旦文件被创建,IE就会显示文件下载"建议打开"、保存"和取消"选项的弹出窗口.

Javascript 有没有办法从我的网页中知道此弹出窗口何时关闭,即用户何时保存(或打开)PDF 文件?

更准确地说,在显示 PDF 文件链接的网页中,会显示一个模式弹出窗口(等待弹出窗口"),以使用户等待文件下载"弹出窗口.问题是当用户保存(或打开)PDF 文件时,文件下载"弹出窗口关闭,但用户随后返回"到原始网页,等待弹出窗口仍然显示.

请注意,我的应用程序仅在 IE6 中运行,因此我不反对仅使用 IE(6) 的解决方案...

我对需要 jQuery 的解决方案也没有问题;)

如果存在一种解决方案来捕获在文件下载"弹出窗口显示给用户时(即在用户选择保存、打开或取消之前)准确触发的任何事件,那么对我来说也没有问题!

解决方案

我不得不在另一个项目上处理此类问题.我终于找到了一个聪明的解决方案,如另一个 Stackoverflow 问题所述.>

解释在以下帖子中给出:http://gruffcode.com/2010/10/28/detecting-the-file-download-dialog-in-the-browser

这个想法是简单地"使用 cookie 来定义文件何时被下载.

I have a web page (made with JSF) where some links allow the user to get a PDF file.

When the user clicks on such a link, a waiting popup (it is a modal panel) is displayed (because the generation of the PDF can be long), and once the file is created, IE displays the "File download" popup that proposes "Open", "Save" and "Cancel" options.

Is there a way in Javascript to know from my web page when this popup is closed, i.e. when the user has saved (or opened) the PDF file?

To be a little more precise, in the web page that displays the link to the PDF file, a modal popup is displayed (the "waiting popup") in order to make the user waits for the "File download" popup. The problem is that when the user Saves (or open) the PDF file, the "File download" popup closes, but the user then "returns" to the original webpage, with the waiting popup still displayed.

Note that my application runs only in IE6, so I am not against a IE(6)-only solution...

I have also no problem with solutions that need jQuery ;)

Edit: If a solution exists to catch any event that is fired exactly when the "File download" popup is displayed to the user (i.e. before the user chooses to Save, Open or Cancel), it will be fine for me too!

解决方案

I had to work on this kind of issue, on another project. I finally found a smart solution, as explained in another Stackoverflow question.

The explanation is given in the following post: http://gruffcode.com/2010/10/28/detecting-the-file-download-dialog-in-the-browser

The idea is to "simply" use a cookie to define when the file is downloaded.

这篇关于检测何时“文件下载"弹出窗口已关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆