Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the browser cursor from "wait" to "auto" without the user moving the mouse

I use this jQuery code to set the mouse pointer to its busy state (hourglass) during an Ajax call...

$('body').css('cursor', 'wait'); 

and this corresponding code to set it back to normal...

$('body').css('cursor', 'auto'); 

This works fine... on some browsers.

On Firefox and IE, as soon as I execute the command, the mouse cursor changes. This is the behavior I want.

On Chrome and Safari, the mouse cursor does not visibly change from "busy" to "auto" until the user moves the pointer.

What is the best way to get the reluctant browsers to switch the mouse pointer?

like image 808
Nosredna Avatar asked Nov 11 '09 22:11

Nosredna


People also ask

How do I get my mouse cursor back to normal?

Press Windows Key +I and go to Ease of access and select Mouse option from the left Pane and try to set default settings for mouse and see if it helps. Hope this information was helpful.

How do I turn on cursor mode?

To access mouse settings, select the Start button, then select Settings > Ease of Access > Mouse . Turn on the toggle under Control your mouse with a keypad if you want to control your mouse using a numeric keypad.


2 Answers

I would rather do it more elegantly like so:

$(function(){     $("html").bind("ajaxStart", function(){        $(this).addClass('busy');      }).bind("ajaxStop", function(){        $(this).removeClass('busy');      });   }); 

CSS:

html.busy, html.busy * {     cursor: wait !important;   }   

Source: http://postpostmodern.com/instructional/global-ajax-cursor-change/

like image 175
Korayem Avatar answered Sep 17 '22 12:09

Korayem


It is a bug in both browsers at the moment. More details at both links (in comments as well):

http://code.google.com/p/chromium/issues/detail?id=26723

and

http://code.google.com/p/chromium/issues/detail?id=20717

like image 27
user213788 Avatar answered Sep 17 '22 12:09

user213788