473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How can I dump the HREF and still have the cursor turn to a hand?

I used a bit of JS on a page that is fairly long and didn't like the
way that

<A HREF='#' ONCLICK=\"...

refreshed the page to the top. Removing the HREF (<A ONCLICK=\"...)
solved my "problem" however the cursor no longer changes into the
little hand when rolling over the link. Can I have both? No HREF and
the little hand?

Thanks in advance for a push in the right direction! :)
Jul 23 '05 #1
10 2814


Bill H wrote:
I used a bit of JS on a page that is fairly long and didn't like the
way that

<A HREF='#' ONCLICK=\"...

refreshed the page to the top.
You could use
<a href="#" onclick="...; return false;">
to prevent that.
Removing the HREF (<A ONCLICK=\"...)
solved my "problem" however the cursor no longer changes into the
little hand when rolling over the link. Can I have both? No HREF and
the little hand?


Use CSS
<style type="text/css">
a.whatever {
cursor: pointer;
}
</style>

<a class="whatever">
Should do with Netscape 7, IE 6, Opera 7, Mozilla

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2
"Bill H" <maylar69@hot----.com> wrote in message
news:91********************************@4ax.com...
I used a bit of JS on a page that is fairly long and didn't like the
way that

<A HREF='#' ONCLICK=\"...

refreshed the page to the top. Removing the HREF (<A ONCLICK=\"...)
solved my "problem" however the cursor no longer changes into the
little hand when rolling over the link. Can I have both? No HREF and
the little hand?


This can be done with CSS rather than Javascript. Add "cursor: hand;" to
your style tag, eg:
<a style="cursor: hand;" onclick="doStuff();">A former link</a>

Some other useful values for cursor include:
arrow : the standard pointer
crosshair : the crosshair cursor
help : the "?" cursor
move : the "move window" cursor
text : text selection cursor
wait : hourglass cursor

Also, you can recreate the "resize" cursors (eg those display when resizing
a window from its corner) with the following:
n-resize, s-resize : up/down arrows
e-resize, w-resize : left/right arrows
ne-resize, sw-resize : bottom-left/top-right arrows
nw-resize, se-resize : top-left/bottom-right arrows

Hope that helps.

--

The Blue Raja
"Besides, true evil never shows itself by trying to legitimizing itself.
Take 'Raja, for example. He's an EVIL little bastard and doesn't have to
announce it to the world. He decimates the millions with polite,
conversation and leaves a wake of devastation in his path." - Butch
RGMW FAQ - By order of Yoda Bob
http://www.rgmw.org
Jul 23 '05 #3
Lee
Bill H said:

I used a bit of JS on a page that is fairly long and didn't like the
way that

<A HREF='#' ONCLICK=\"...

refreshed the page to the top.


If you don't want a link to be followed, have your onclick handler
return false. The null anchor, "#", is a link to the top of the
current page.

<a href="#" onclick="...;return false"

will do what you want.

In modern browsers, you can use CSS to set the cursor for any
span of text, and can also assign an onclick handler for such
text, but using the link as above is simpler.

Jul 23 '05 #4
Lee
Blue Raja said:

"Bill H" <maylar69@hot----.com> wrote in message
news:91********************************@4ax.com.. .
I used a bit of JS on a page that is fairly long and didn't like the
way that

<A HREF='#' ONCLICK=\"...

refreshed the page to the top. Removing the HREF (<A ONCLICK=\"...)
solved my "problem" however the cursor no longer changes into the
little hand when rolling over the link. Can I have both? No HREF and
the little hand?


This can be done with CSS rather than Javascript. Add "cursor: hand;" to
your style tag


Unfortunately, the cursor names aren't that well standardized.
IE uses "hand".
Others use "pointer"

Jul 23 '05 #5
Lee <RE**************@cox.net> writes:
Unfortunately, the cursor names aren't that well standardized.
Yes they are :)
IE uses "hand".
Others use "pointer"


.... and IE is wrong. The solution is to do:
---
cursor:pointer; cursor:hand;
---
All browsers except IE will ignore "cursor:hand" because it's not a
recognized value. (IE compounds its problems by not ignoring
"cursor:pointer", but instead recognize it and misinterpret it)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #6
Blue Raja wrote:
<snip>
This can be done with CSS rather than Javascript. Add "cursor:
hand;" to your style tag, eg:
<a style="cursor: hand;" onclick="doStuff();">A former link</a>

<snip>

cursor:hand; is an IE only formulation, the official CSS version is -
cursor:pointer; - but as it is unrecognised by older IE versions a rule
such as:-

..usePointer {
cursor:hand;
cursor:pointer;
}

- can be use. Modern browsers will use the second rule and old IE
versions will ignore the second rules as they will not recognise it.
(Non-IE, standards compliant browsers will not recognise the first so
they will ignore it, only later IE versions would understand both).

An A element without an HREF, NAME or ID is not really an A element
(neither a link nor an anchor) so it would probably make more sense to
be using some other mark-up. In the absence of any context information a
SPAN would be sufficient for the task. A major difference between those
two elements is how thy function with keyboard navigation. But an A
element without an HREF attribute is going to be outside keyboard
navigation anyway (just like a SPAN).

Setting the cursor CSS property in a STYLE attribute means that it would
be used whenever CSS was supported on the browser, but CSS support is
independent from javascript support (except on Netscape 4). The user of
a javascript incapable/disabled browsers that supports CSS would be left
with the impression that the element was supposed to do something
(because of the cursor) but clicking on the element will do nothing. To
avoid the confusion it is generally better to have javascript apply the
CSS so that it is only used when there is a chance that using the
element will actually do something:-

<style onclick="doStuff();"
onmouseover="this.className='usePointer';this.onmo useover=null;">
Not a Link</span>

Though it is difficult to see the resulting element as being a
contribution to a web page when it is not capable of doing anything
(even without the cursor style). As a result it makes most sense to have
the UI widgets that relate to javascript dependent functionality created
with javascript, using - document.write -, - innerHTML - or with W3C DOM
Node creation and insertion techniques (accompanied by appropriate
feature detection to verify that the browser supports the related
functionality). So that the user is never presented with a UI component
that is incapable of delivering whatever it promises to do.

<input type="button"> elements also make good candidate as devices for
triggering javascript dependent functionality where no viable
alternative can be provided, and can be substantially styled on more
recent and co-operative browsers.

Ultimately the simplest approach has go to be using the A element with
an HREF attribute, cancelling the default action associated with the
onclick handler (the navigation) and providing a URL for the HREF that
either re-produces the functionality remotely (using server-side
scripting) or explains, and apologises for, the javascript dependency in
the UI design.

That way you have the desired cursor as a matter of course, viable
keyboard access and an item on the page that makes sense to the user
however it is allowed to work.

Richard.
Jul 23 '05 #7
On Sat, 17 Jul 2004 17:17:17 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com> wrote:
Lee <RE**************@cox.net> writes:
Unfortunately, the cursor names aren't that well standardized.


Yes they are :)
IE uses "hand".
Others use "pointer"


... and IE is wrong. The solution is to do:
---
cursor:pointer; cursor:hand;
---
All browsers except IE will ignore "cursor:hand" because it's not a
recognized value. (IE compounds its problems by not ignoring
"cursor:pointer", but instead recognize it and misinterpret it)

/L


Thanks everyone, you rock! :)
Jul 23 '05 #8
"Richard Cornford" <Ri*****@litotes.demon.co.uk> writes:
.usePointer {
cursor:hand;
cursor:pointer;
}

- can be use. Modern browsers will use the second rule and old IE
versions will ignore the second rules as they will not recognise it.


Would be great, but IE has a bad habit of not ignoring unrecognized
values. Just as for "position:fixed", IE 5.5 (maybe also other
versions) will *not* ignore "cursor:pointer", but will treat it as
"cursor:default". To work, the rules must be swapped.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #9
Lasse Reichstein Nielsen wrote:
Richard Cornford writes:
.usePointer {
cursor:hand;
cursor:pointer;
}
<snip> ... . To work, the rules must be swapped.


Yes, you are right. I should have looked up an example instead of
relying on my memory (it is not always that good :)

Richard.
Jul 23 '05 #10
Lasse Reichstein Nielsen wrote:
Lee <RE**************@cox.net> writes:
Unfortunately, the cursor names aren't that well standardized.


Yes they are :)


Which is why ...
IE uses "hand".
Others use "pointer"


... and IE is wrong. The solution is to do:
---
cursor:pointer; cursor:hand;


.... this is a solution, but not Valid CSS.
PointedEars
Jul 23 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hoang | last post by:
does anyone know how to dump the table structure and data from a mysql database? I am connected to the database externally so "SELECT * FROM database INTO OUTFILE file" doesn't work for me. ...
4
by: KS | last post by:
Im trying to prevent the user from clicking any other links on my page when the user have selected/clicked a href once. Sometimes it takes a while before the next page loads so some user will try...
1
by: Bernd Liebermann | last post by:
Hi, I need some help on a simple question: I have a link that should open a new window (no action in main window), which is realized by a function that calls window.open(). The function itsself...
9
by: Chris Michael | last post by:
I am using the following class in a CSS document: ..loginsubmit { background-color: #ffffff; FONT-WEIGHT: bold; color: #002980; cursor: hand } It works perfectly well, but it won't validate...
2
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display...
2
by: Saber S | last post by:
When I press Alt+Shift in a text control, the cursor turns Right-To-Left. I want it without pressing Alt+Shift, I want to when I click a text control the cursor automatically turn to Right-To-Left.
5
by: Jeronimo Bertran | last post by:
I have an <a href=url> inside an Iframe.... when I click it, the url is navigated inside the frame... what do I need to do in order to navigate the url on the browser window and NOT the iframe?? ...
6
by: Tomek | last post by:
In my page I reload JavaScript. When it is reloading the cursor change to "wait" (hourglass). After javascript loaded it does not change back to the "hand" if cursor stay on hyperlinks. How can I...
10
by: Edwin Knoppert | last post by:
I have an asp.net imagebutton with a clickevent. I have enclosed an anchor around the image and a small text. If i click the image the event is executed (while the href of the anchor shows in the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.