DidierD
asked on
Change MousePointer
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='w ait';
imSort(); //this code takes long to excecute
window.document.body.style .cursor='d efault';
}
I saw somewhere an example with setTimeout but i could not get it to work.
Didier
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
imSort(); //this code takes long to excecute
window.document.body.style
}
I saw somewhere an example with setTimeout but i could not get it to work.
Didier
this works for me :
<html>
<head>
<script>
function test()
{
window.document.body.style .cursor='w ait'
}
</script>
<title>Page title</title>
</head>
<body onload='test()'>
</body>
</html>
Partha
<html>
<head>
<script>
function test()
{
window.document.body.style
}
</script>
<title>Page title</title>
</head>
<body onload='test()'>
</body>
</html>
Partha
you need this
function myfunction(){
window.document.body.style .cursor='w ait';
imSort(); //this code takes long to excecute
}
function imSort() {
.
.
.
window.document.body.style .cursor='d efault';
}
function myfunction(){
window.document.body.style
imSort(); //this code takes long to excecute
}
function imSort() {
.
.
.
window.document.body.style
}
ASKER
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
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
for(i=0;i<10000;i++){
overviewSection.innerHTML = "test" + i;
}
window.document.body.style
}
function sort(){
for(i=0;i<10000;i++){
overviewSection.innerHTML = "test" + i;
}
window.document.body.style
}
function test2(){
window.document.body.style
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
ASKER
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.curs or = 'wait';
}
function resetPointer() {
if (document.all) for (var i=0;i < document.all.length; i++) document.all(i).style.curs or = '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
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.curs
}
function resetPointer() {
if (document.all) for (var i=0;i < document.all.length; i++) document.all(i).style.curs
}
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
What is the differrnce form your solution to the one I posted besides you calling a function???
Oh, ok...
ASKER
I use the setTimeout() function.
Also the setPointer and resetPointer functions are different. With window.document.body.style .cursor='w ait' 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
Also the setPointer and resetPointer functions are different. With window.document.body.style
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
document.body.style.cursor
jbosch(vosk)