光标未返回其默认状态

时间:2020-09-09 16:02:20

标签: javascript asp.net cursor busy-cursor

我想在下载时显示繁忙的光标。并按预期工作,但单击事件结束后,光标仍显示繁忙。下载完成后,即点击事件结束后,我想恢复到默认设置。

页面加载:

btnGenerate.Attributes.Add("onclick", "waitdownload();");

Aspx:

<script>
   function waitdownload() {
       document.body.style.cursor = "wait";
   }
</script>

1 个答案:

答案 0 :(得分:0)

您可以使用等待x秒的超时来执行另一段代码。

<script>
    function waitdownload() {
        document.body.style.cursor = "wait";

        //wait 5 seconds to set the cursor to default
        setTimeout(function () {
            document.body.style.cursor = "default";
        }, 5000);
    }
</script>