javascriptasp.netcursorbusy-cursor

Cursor not returning to its default State


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>

Solution

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