Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wait cursor doesn't show..

    Hi all,

    Just wondering if anyone has ever written a computational function that takes a while to run, and has ever considered changing the mouse cursor to the hourglass while the function is running.

    I tried... no success. I'm not sure what I'm doing wrong either! This is essentially the format of the code -- if you know what's wrong, please let me know!

    Code:
     function longFunction() {
      document.body.style.cursor = "wait";
      ...
      document.body.style.cursor = "auto";
     }
    My code only needs to run in IE. There are no return statements within the function either.

    PS. I've found that when my function fails -- so there's a Javascript error midway -- it kicks out the function, so as not to execute the line of code changing the cursor back to "auto". At this point the cursor becomes the hourglass! So it works, just not when I want it to...

    Thanks in advance,
    Sadiq.
    Last edited by sad69; 04-19-2004 at 11:15 PM.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Try putting a little delay.

    setTimeout("document.body.style.cursor = 'wait'", 1);
    ...
    setTimeout("document.body.style.cursor = 'auto'", 1);
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nope, didn't work..

    Any other suggestions? I'd really like for this to work as my clients are a bit older and seem to not have much patience. I don't think it's best if they get double clicking buttons and stuff just because it's taking long. I think the hourglass will give them a bit of a clue that they'll have to wait.

    But it's not working...

    Thanks,
    Sadiq.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    I have tested this and it works
    Code:
    function executeFunctionWithCursor(){
       document.body.style.cursor = "wait";
       setTimeout("longFunction()", 1);
       setTimeout("document.body.style.cursor = 'auto'", 1);
    }
    
    function longFunction() {
       //long processing here
    }
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •