More Accurate.
<script>
document.body.style.cursor
</script>
<body onLoad="document.body.curs
Main Topics
Browse All TopicsI have an html table on my page that I allow the user to sort by column when he clicks on the heading for a particular column. I want to display a wait cursor during the sorting so he knows it's working and then reset when finished.
I've been trying to use objectName.cursor.style = "wait" at the beginning of the sort function, and then resetting at the end.
problem is, this style change doesn't take effect until the function terminates. by that time, the sort is done, and it's obviously too late.
does anyone know how I can accomplish my aim in a simple way?
*****
my code:
function tableSort( tableId, iSortColumn, format )
{
var eSrc = window.event.srcElement;
var savedCursor = getObjCursor( eSrc );
setObjCursor( eSrc, "wait");
// sort code
setObjCursor( eSrc, savedCursor );
return;
}
function setObjCursor( obj, cursor )
{
if( obj && obj.style && obj.style.cursor != cursor )
obj.style.cursor = cursor;
return;
}
function getObjCursor( obj )
{
if( obj && obj.style )
return obj.style.cursor;
}
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
instead of
function doSomething( ... ) {
set wait cursor
do a lot of work
set normal cursor
}
you can make 2 functions:
function startSomething( ... ) {
set wait cursor
setTimeout( "doSomething( ... )", 50 ); // wait 50 ms before starting the real work so cursor have time to change
}
function doSomething( ... ) {
do a lot of work
set normal cursor
}
note that you now cannot use the return from the function to know that the work has been done. You might need to make the function started by setTimeout trigger some event to get a notification of when the sorting is done.
regards JakobA
Worth a try would be also:
var eSrc ;
var savedCursor;
function tableSort( tableId, iSortColumn, format )
{
eSrc = window.event.srcElement;
savedCursor = getObjCursor( eSrc );
window.setTimeout('setObjC
// sort code
window.setTimeout('setObjC
return;
}
mattjp88 and adilkhan seem to have missed the point.
jakobA, I think your solution will work. this is actually what I had begun to do. it does not seem elegant to me, especially since you're resetting the cursor in a different function than the one in which you set it. this would require sharing of information bet. the two functions - info. 1) of the old cursor, and 2) on which object to set the cursor.
this is not the prettiest.
I will probably want to attach these pieces of info. to a shared object rather than pass them into the 2nd function.
but aside from that, your answer is excellent, I think.
abie
btw, I did try zvonko's suggestion in the end. it didn't work for me.
this was the code:
var evtSrc;
var savedCursor;
function tableSort( tableId, iSortColumn, format )
{
evtSrc = window.event.srcElement;
savedCursor = getObjCursor( evtSrc );
var sCode = 'setObjCursor( evtSrc, "wait" );'
setTimeout( sCode, 1 );
//sorting code //
sCode = 'setObjCursor( evtSrc, savedCursor );'
setTimeout( sCode, 1 );
return;
}
Business Accounts
Answer for Membership
by: mattjp88Posted on 2003-09-23 at 15:29:00ID: 9416676
<script> ="wait";
document.body.style.cursor
</script>
-Matt