Cursor not returning to its default State

123 views Asked by At

I want to show busy cursor while downloading. and its working as expected but after click event ends still cursor showing busy. I want to roll back to its default after download completed i.e. after click events ended.

on Page load :

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

Aspx :

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

There are 1 answers

3
VDWWD On BEST ANSWER

You could use a Timeout that waits x second to execute another piece of code.

<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>