Solved

Change MousePointer

Posted on 2003-10-27
10
862 Views
Last Modified: 2011-09-20
Hi,

I have a function that takes some time to execute. During that time i want to change the MousePointer to a hourglass. i tried some different approaches, but they all failed.

function  myfunction(){

  window.document.body.style.cursor='wait';

  imSort(); //this code takes long to excecute  

  window.document.body.style.cursor='default';

}

I saw somewhere an example with setTimeout but i could not get it to work.

Didier
0
Comment
Question by:DidierD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 3

Expert Comment

by:vosk
ID: 9627232
that works on my msie
document.body.style.cursor = "wait";
jbosch(vosk)
0
 
LVL 14

Expert Comment

by:p_partha
ID: 9627854
this works for me :

<html>
<head>
<script>
function test()
{
window.document.body.style.cursor='wait'
}
</script>
<title>Page title</title>
</head>
<body onload='test()'>



</body>
</html>

Partha
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 9628608
you need this

function  myfunction(){

  window.document.body.style.cursor='wait';

  imSort(); //this code takes long to excecute  


}

function imSort() {
.
.
.

  window.document.body.style.cursor='default';

}
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Author Comment

by:DidierD
ID: 9633241
Hi,

Thanks for the suggestions. But they don't work for me. Maybe i did not explain well enough what i was doing. Here is a better simplified example.

<html>
<head>
<script language=javascript>
function test1(){
  window.document.body.style.cursor = "wait";
  for(i=0;i<10000;i++){
    overviewSection.innerHTML = "test" + i;
  }
  window.document.body.style.cursor = "default";
}

function sort(){
  for(i=0;i<10000;i++){
    overviewSection.innerHTML = "test" + i;
  }
  window.document.body.style.cursor = "default";
}

function test2(){
  window.document.body.style.cursor = "wait";
  sort();
}

</script>

<title></title>
</head>
<body>
<input type=button name=btn1 value="Click1" onclick="test1()">
<input type=button name=btn2 value="Click2" onclick="test2()">
<br>

start div
<div id='overviewSection'>
</div>
end div

</body>
</html>

mplungjan: as you can see i tried your solution, but the mouse pointer stays the same :(
p_partha: your solution is not really what i want, see example

I also increased the point to 150.

Didier
0
 
LVL 2

Author Comment

by:DidierD
ID: 9633364
I just found a solution myself. This seems to work.

function sort(){
  for(i=0;i<10000;i++){
    overviewSection.innerHTML = "test3" + i;
  }
  resetPointer();
}

function test3(){
   setPointer();
   setTimeout('sort()',1);
}
function setPointer() {
    if (document.all) for (var i=0;i < document.all.length; i++) document.all(i).style.cursor = 'wait';
}
function resetPointer() {
   if (document.all) for (var i=0;i < document.all.length; i++) document.all(i).style.cursor = 'default';
}

I leave this question open for a day, in case somebody has a better solution. If there is no better solution i will delete it.

Thanks
Didier
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 9634190
What is the differrnce form your solution to the one I posted besides you calling a function???
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 9634193
Oh, ok...
0
 
LVL 2

Author Comment

by:DidierD
ID: 9634502
I use the setTimeout() function.
Also the setPointer and resetPointer functions are different. With window.document.body.style.cursor='wait' it doesn't work.

I found this solution somewhere on the internet. I'm totally new to this stuff, so if you can give me a good explanation about why this works and the other solutions not, you can still have the points.

Greetz,
Didier

BTW i'm going home now, i'm back tomorrow
0
 

Accepted Solution

by:
SpazMODic earned 0 total points
ID: 9742983
PAQed, with points refunded (150)

SpazMODic
EE Moderator
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question