Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 23rd, 2004, 10:35 AM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hour glass cursor

Hi all,

I just wanted to know if there is a command in javascript to change the cursor on a webpage to an hour glass without the use of a for loop.

I have a javascript function that's running for a more than a couple of seconds and I want to change the cursor to an hour glass when this function is being executed.

I would really appreciate any help.

Thanks,
Qadeer.

Reply With Quote
  #2 (permalink)  
Old April 23rd, 2004, 12:18 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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

I think that'll do it....

Snib

<><
Reply With Quote
  #3 (permalink)  
Old April 23rd, 2004, 01:34 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Snib,

Thanks for the reply.

If I use document.body.style.cursor='wait' the cursor doesn't show the hour glass when hovering over buttons or other controls on the web page.

Here is what I am trying to do: I have a button on my webpage and when I click on the button it is enabling and changing the values in a number of textboxes. This takes about 3-4 seconds. Now when this is being done I want to change the cursor to an hour glass. So as soon as the user clicks on the button I want the cursor to change to hour glass and after the execution of my function I want it to change back to default. I am trying to acheive this using the following code on button click:

on_button_click()
{
 document.body.style.cursor='wait';
 myfunction(); // This takes about 3-4 seconds to execute
 document.body.style.cursor='default';
}

This still doesn't give me the desired result.
What am I doing wrong? or is there any other way I can acheive this?

Thanks,
Qadeer

Reply With Quote
  #4 (permalink)  
Old April 23rd, 2004, 01:47 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

At the beginning of myfunction() put the 'wait' code and at the end put the 'un-wait' code.

I might have the 'wait' thing all wrong.......

HTH,

Snib

<><
Reply With Quote
  #5 (permalink)  
Old April 23rd, 2004, 01:55 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried that too.. still same result.. :-(

Qadeer

Reply With Quote
  #6 (permalink)  
Old April 23rd, 2004, 07:52 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

I would suggest using the universal selector to apply the cursor property, here is a brief demonstration of how to do it:

Code:
<html>
    <head>
        <title> Universal Selector </title>
        <style type='text/css'>

            * {
                cursor: auto;
            }

        </style>
    </head>
    <body>
        <script language'JavaScript' type='text/javascript'>

            document.styleSheets[0].rules[0].style.cursor = 'wait';

        </script>
    </body>
</html>
The universal selector will apply the style to *all* rendered elements.

This works fine in IE, but so far I haven't been able to get a working equivalent in Mozilla.

hth,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
Reply With Quote
  #7 (permalink)  
Old April 24th, 2004, 04:43 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Here is the Mozilla/Safari, etc equivalent:
document.styleSheets[0].cssRules[0].style.cursor = 'wait';

Regards,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
Reply With Quote
  #8 (permalink)  
Old April 26th, 2004, 10:18 AM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you rich..

Qadeer

Reply With Quote
  #9 (permalink)  
Old October 13th, 2008, 07:43 AM
Registered User
 
Join Date: Oct 2008
Location: Gurgaon, Haryana, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi All,
Anybody tell me that hour glass is appearing in firefox but not in IE7 on our server but on client server it is not running. Is it the case that on our OS it is supported but not in their server.?

Please help me.........

Thanks
-Sankalp

Reply With Quote
  #10 (permalink)  
Old August 7th, 2009, 10:36 PM
dutchlady123
Guest
 
Posts: n/a
Default

Many thanks to ur post. I love it.


demande simulation pret personnel en ligne - Pret personnel en ligne et de comparer les meilleurs taux afin de... La demande de prêt personnelen lignedemande simulation pret personnel en ligne
Reply With Quote Received Infraction
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Glass button look kuznickic ASP.NET 2.0 Basics 0 October 28th, 2008 02:13 AM
Hour by Hour Matrix Report Ed_Conde BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 August 12th, 2008 02:51 PM
Magnetic Cursor - Target Area Cursor? gcarcass .NET Framework 2.0 1 May 5th, 2008 07:20 AM
Aero glass in vb6 using win xp sp2 svharishtech Pro VB 6 2 July 7th, 2007 12:04 AM
Timesheet hour value problem geoffers BOOK: Beginning VB.NET Databases 5 August 24th, 2005 04:30 AM



All times are GMT -4. The time now is 10:12 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.