[thelist] busy cursor (was: close window js)

jeff jeff at members.evolt.org
Fri Jun 1 12:45:21 CDT 2001


joshua & jon,

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Jonathan Chard
:
: > From: Joshua Olson
: >
: > Using the javascript/void technique has a
: > tendency to convert the mouse icon to an
: > hourglass without ever changing it back.
: > Not all combinations of browser/os have
: > this problem, but I do see it on my NT/ie
: > combination from time to time.
:
: Aha! I'm glad someone mentioned this, because
: I've seen it on occasion too, but didn't know
: why. I found an investigation into this at:
:
:
http://web-wise-wizard.com/javascript-tutorials/browser-phantom-busy-cursor.
html
:
: .. that seems to suggest that using
: javascript:void(0) is actually a way of avoiding
: it, but.. well, I'm not convinced (probably unfairly,
: I'm just biased because I think their site is horrid).
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

what causes the busy cursor is simple -- not issuing a return false in the
onclick event handler of an <a> tag that does nothing more than to execute
some javascript.  the browser falsely assumes all anchors are for
navigation -- whether within a page to a named anchor or to another page.
since this operation involves changing the cursor to give the user a cue
that their action is being dealt with, it makes sense that clicking an <a>
tag would change the cursor.

however, in the case with <a> tags that are simply used to execute
javascript, the user isn't being taken anywhere by the browser.  the user
clicks on the link, the browser changes the cursor, and executes the
javascript.  there's no page changing or navigation to a named anchor so no
clue to the browser when to change the cursor back to the default.

the solution is to tell the browser that it's done by issuing a return false
in the onclick.  that tells the browser to execute the javascript and then
stop what it's doing.

<a
 href="JavaScript://"
 onClick="alert('Hi'); return false"
>Click me!</a>

as a sidenote, use the void(0) method sparingly and only when you know for
certain your browser audience.  it was introduced with js1.1 and therefore
not compatible with the first generation of javascript-compatible browsers.
this may not be an issue for alot of you, but only if you know your audience
and their browser choices.

good luck,

.jeff

name://jeff.howden
game://web.development
http://www.evolt.org/
mailto:jeff at members.evolt.org





More information about the thelist mailing list