我正在尝试解决以下问题,但我想不出合适的解决方案:
Disabling a button (with an underlying Download link) when the download starts (button has clicked once) and enable the button again when the download is completed?
我尝试用 Google 搜索它,但甚至找不到有用的提示。这在一般情况下甚至可能吗?
最佳答案
您可能想要查看的 3 个可能选项。
作为开始的地方,此链接可能对您有用:
http://gruffcode.com/2010/10/28/detecting-the-file-download-dialog-in-the-browser/
想法是使用 cookie 来定义何时下载文件。理论上,您可以编写 JavaScript 来检测 cookie,然后重新启用按钮。可以在这里找到用 JavaScript 检测 cookie 的一个很好的概述:What is the shortest function for reading a cookie by name in JavaScript?
另一个解决方案可能是看看这个问题: detecting when the "File download" popup is closed
虽然这不是您要找的东西 - Crescent Fresh 的答案可能会有所调整,以便在下载期间禁用您的按钮。
或者一个快速但不优雅的解决方案是禁用下载按钮 30 秒到 2 分钟之间的某个时间,以防止用户在文件下载时立即再次单击该按钮 - 这是最不奏效的方法,但它不是考虑到不同的下载速度等。
希望对您有所帮助!
关于spring-mvc - 是否可以在下载完成之前禁用按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31940342/