下载pdf后如何停止进度指示器 [英] how to stop progress indicator after downloading a pdf

查看:66
本文介绍了下载pdf后如何停止进度指示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上有一个指向pdf文件的链接.单击该链接需要花费很长时间,因此我想抛出一个进度指示器gif,以表明它需要一些时间.但是,一旦在服务器端生成了pdf文件并完成了下载,如何隐藏指示器? (基本上,您的浏览器现在说您正在打开pdf文件并询问您该怎么做)

There is a link on my page to a pdf file. Clicking on the link takes a really long time, so I'd like to throw up a progress indicator gif showing that it is something that takes a while. But how do you hide the indicator once the pdf has been generated on the server side and finished downloading? (basically your browser now says you are opening a pdf file and asks you what to do)

这时是否有事件触发或我可以轮询以隐藏进度指示器的任何东西?

at this point is there an event that fires or anything I can poll to check to hide the progress indicator?

推荐答案

JavaScript无法访问有关所下载内容的信息.您唯一可以做的就是将PDF加载到iframe中,并在iframe上挂接onload事件.即使这样,该事件也会在PDF开始加载时触发,而不是在完成时触发.

JavaScript does not have access to information on what's being downloaded. The only thing you can do is load the PDF in a Iframe and hook up the onload event on the Iframe. Even then the event will fire when the PDF starts loading, not when it is complete.

编辑: kalendae 有替代答案.

如果您具有服务器端访问权限,则可以设置带有响应的cookie并在客户端上轮询其值.

If you have server-side access you can set a cookie with the response and poll for its value on the client.

请参阅: 查看全文

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