Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to change mouse cursor after click on button using java sript.
i used document.all.ShowPages.style.cursor = "hand"; this one is not working.

please send me answer soon

thanks
Posted
Updated 1-Feb-11 19:55pm
v2

I tried, it does not work; "document.all" also does not work.
Why not "document.body.style.cursor = 'wait';"? — it works.

—SA
 
Share this answer
 
Comments
Manas Bhardwaj 2-Feb-11 5:10am    
document.all is IE specific thing(which I hate :().
Same is the case with 'hand' cursor. One should always use 'pointer'
Sergey Alexandrovich Kryukov 2-Feb-11 13:26pm    
I agree.
I would probably hate it even more if I had to deal with that crap. I prefer don't touch such things and would advice it for anyone. Anyway, my sample works in Firefox/Seemonkey as well; and the area covered is actually whole page.
Thank you.
--SA
Sandeep Mewara 2-Feb-11 13:43pm    
Oh ye sure... Proposed answer.
5!
Espen Harlinn 2-Feb-11 16:33pm    
Good answer - 5+
Here[^] you go for all valid values for Cursor style.

For cross browser,
MIDL
style="cursor: pointer; cursor: hand;"
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-Feb-11 13:27pm    
Thank you Sandeep, it's good (my 5).
However, the problem was ".all", see my answer (it works) and the comment by Manas.
--SA
Espen Harlinn 2-Feb-11 16:34pm    
Nice link - a 5
Hello,

Use the following code:
document.body.style.cursor = "progress";



OR you can use the following code: (This uses CSS class to set cursor)

Style:
XML
<style type="text/css">
        .cursorPointer
        {
            cursor: pointer;
        }
        .cursorPointer2
        {
            cursor: progress;
        }
    </style>


Script:
C#
function Change() {
            document.getElementById("pagebody").className = "cursorPointer2";
            //document.getElementById("pagebody").style.cursor = "progress";
        }


HTML:
<body class="cursorPointer" id="pagebody">
<input type="button" value="ChangeCursor" onclick="resettextbox('Value');" />
</body>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900