Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 23rd, 2004, 10:35 AM
Authorized User
 
Join Date: Apr 2004
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.

 
Old April 23rd, 2004, 12:18 PM
Friend of Wrox
 
Join Date: Nov 2003
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

<><
 
Old April 23rd, 2004, 01:34 PM
Authorized User
 
Join Date: Apr 2004
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

 
Old April 23rd, 2004, 01:47 PM
Friend of Wrox
 
Join Date: Nov 2003
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

<><
 
Old April 23rd, 2004, 01:55 PM
Authorized User
 
Join Date: Apr 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Qadeer

 
Old April 23rd, 2004, 07:52 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
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
::::::::::::::::::::::::::::::::::::::::::
 
Old April 24th, 2004, 04:43 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
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
::::::::::::::::::::::::::::::::::::::::::
 
Old April 26th, 2004, 10:18 AM
Authorized User
 
Join Date: Apr 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you rich..

Qadeer

 
Old October 13th, 2008, 07:43 AM
Registered User
 
Join Date: Oct 2008
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

 
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
Received Infraction





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.