关于spring mvc:是否可以在下载完成之前禁用Button?

Is it possible to disable a Button until download is finished?

我正在尝试解决以下问题,但无法提出适当的解决方案:

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的好方法:在JavaScript中按名称读取cookie的最短函数是什么?

  • 另一个解决方案可能是看这个问题:
    检测"文件下载"弹出窗口何时关闭

    虽然这并不是您所要查找的内容,但可以修改Crescent Fresh的答案,以便在下载期间禁用按钮。

  • 或者一种快速但不完善的解决方案是在30秒到2分钟之间禁用下载按钮,以防止用户在文件下载时立即再次点击该按钮-这是最少的工作,但并不能说明其他问题下载速度等。

  • 希望有帮助!