Digital Point Forums
Moneygram

Go Back   Digital Point Forums > Design & Development > Programming > JavaScript
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old Feb 9th 2005, 4:10 pm
michael_nrw michael_nrw is offline
Peon
 
Join Date: Feb 2005
Posts: 2
michael_nrw is on a distinguished road
change cursor style while calculating

Hi guys,
I have the following problem: If i check a checkbox, an onclick-event jumps into a javascript function, which needs 2-3 seconds before finishing a complex calculation. In this time-period i want to change the cursor style in the status 'wait' (sandbox). After calculation is finished, i want the cursor back in his default status (arrow). I tried many things, but nothing works, anyone can help?

thank you in advance, michael

for example a little javascript-progi:

<html><head><title>Test</title>

<script type="text/javascript">

function calc() {
var dummy = 0;

for (var i=0; i<1000000;i++) {
for (var z=0; i<1000000;i++) {
dummy = dummy + z + i;
}
}

}

</script>
</head><body>
<form name="Formular" action="">
<input type="checkbox" name="Test" value="Testvalue" onClick="calc()"> Only a test
</form>
</body></html>
Reply With Quote
  #2  
Old Feb 9th 2005, 8:18 pm
exam exam is offline
of the Nightfall
 
Join Date: Sep 2004
Location: In front of the monitor
Posts: 2,407
exam is just really niceexam is just really niceexam is just really niceexam is just really niceexam is just really nice
Here you go, and free of charge
Code:
<html><head><title>Test</title>

<script type="text/javascript">

function cursor_wait() {
  document.body.style.cursor = 'wait';
}

function cursor_clear() {
  document.body.style.cursor = 'default';
}

function calc() {
  var dummy = 0;

  for (var i=0; i<1000000;i++) {
    for (var z=0; i<1000000;i++) {
      dummy = dummy + z + i;
    }
  }

  cursor_clear();
}

</script>
</head><body>
<form name="Formular" action="">
<input type="checkbox" name="Test" value="Testvalue" onMouseDown="cursor_wait()" onMouseUp="calc()"> Only a test
</form>
</body></html>
EDIT: For compatibility, instead of using:
Code:
document.body.style.cursor
do something like this:
Code:
  var cursor = 
     document.layers ? document.cursor :
     document.all ? document.all.cursor :
     document.getElementById ? document.getElementById('cursor') : null;
__________________
Submit your siteSubmit your article
Reply With Quote
  #3  
Old Feb 10th 2005, 5:11 am
michael_nrw michael_nrw is offline
Peon
 
Join Date: Feb 2005
Posts: 2
michael_nrw is on a distinguished road
perfekt....good trick with the onMouseDown-Event!

thank you very much, greetings from germany, bye michael
Reply With Quote
  #4  
Old Feb 10th 2005, 1:10 pm
exam exam is offline
of the Nightfall
 
Join Date: Sep 2004
Location: In front of the monitor
Posts: 2,407
exam is just really niceexam is just really niceexam is just really niceexam is just really niceexam is just really nice
you're welcome
__________________
Submit your siteSubmit your article
Reply With Quote
  #5  
Old Mar 2nd 2009, 11:55 am
Skews Me Skews Me is offline
Peon
 
Join Date: Mar 2009
Posts: 1
Skews Me is on a distinguished road
getElementById for cursor?

I tried testing this on Firefox:

Code:
alert(document.layers ? document.cursor : document.all ? document.all.cursor : document.getElementById ? document.getElementById('cursor') : null);

alert(document.all);

alert(document.all.cursor);
The results, are "null", "...object...", "undefined"

I'm at a loss of how to gracefully create an element(s) with ID=cursor to change to a 'pointer' and then back to 'default'.
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you change your Email address for Adsense? hulkster Guidelines / Compliance 6 Apr 26th 2007 6:32 pm
No change today nevetS Keyword Tracker 26 Feb 6th 2005 9:21 pm
site content change , but google ads not change complete .why? heelz Placement / Reviews / Examples 6 Jan 31st 2005 9:34 am
URL Change and Language Option hoboseo Co-op Advertising Network 2 Nov 30th 2004 7:55 am
Change order of keywords? Geir Keyword Tracker 2 Sep 20th 2004 7:56 am


All times are GMT -8. The time now is 4:20 am.