•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 397,880 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,703 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 7067 | Replies: 5
![]() |
•
•
Join Date: Jul 2005
Location: Downingtown
Posts: 56
Reputation:
Rep Power: 4
Solved Threads: 3
I need a tag that doesn't go anywhere when I click on it but will show the little hand with index finger outstretched like I am hovering over the text teh tag applies to. I googled for a while, but could not find anything related to what I am looking for. I need this because I am writing a file that will execute a javascript function when I click on it, which will display some new information, so I want it to appear to the user that he/she is clicking on a link.
•
•
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation:
Rep Power: 7
Solved Threads: 107
<A HREF="#">Link Here</A>
•
•
Join Date: Jul 2005
Location: Downingtown
Posts: 56
Reputation:
Rep Power: 4
Solved Threads: 3
Thanks for the reply, but I found something even better, and I am a little embarrassed that I forgot I could do this.
Much simpler. Only thing is I usually hate these links cause I always click links with my middle mouse button to open a new tab in firefox lol.
<a href="javascript:display_spaces()">Get spaces</a>
Much simpler. Only thing is I usually hate these links cause I always click links with my middle mouse button to open a new tab in firefox lol.
•
•
Join Date: Apr 2006
Location: Porterville, CA
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Originally Posted by hinde
Thanks for the reply, but I found something even better, and I am a little embarrassed that I forgot I could do this.
<a href="javascript:display_spaces()">Get spaces</a>
Much simpler. Only thing is I usually hate these links cause I always click links with my middle mouse button to open a new tab in firefox lol.
Or even simpler and "W3C Correct"
<span style="cursor: hand;">Text with Hand Icon</span>
If you're feeling sassy you could even tie that span to a class and add that to the CSS file to keep your code cleaner and more efficent. Using an anchor when not needed is ghetto!
The last suggestion is the best. An anchor tag with the href set to "#" will navigate to the TOP of the page when clicked, which isn't quite the same thing as "go nowhere".
Similarly, using an empty JavaScript is... well, silly, in my opinion.
So I second IAMMATT's suggestion: just style a normal element, such as span, to display the hand cursor.
However, here's my standard scold: When a user sees their cursor turn to a hand, they expect that clicking will DO SOMETHING, in particular, that they will navigate somewhere.
So, creating an element that gives the hand cursor but that does nothing, violates the User Model, which is very nearly always a bad, bad idea.
EDIT: I re-read your original post. You want a hyperlink that runs a Javascript when clicked, so the
Similarly, using an empty JavaScript is... well, silly, in my opinion.
So I second IAMMATT's suggestion: just style a normal element, such as span, to display the hand cursor.
However, here's my standard scold: When a user sees their cursor turn to a hand, they expect that clicking will DO SOMETHING, in particular, that they will navigate somewhere.
So, creating an element that gives the hand cursor but that does nothing, violates the User Model, which is very nearly always a bad, bad idea.
EDIT: I re-read your original post. You want a hyperlink that runs a Javascript when clicked, so the
<a href="javascript:myFunction();">Run your function</a> is the proper method for this. •
•
Join Date: Feb 2006
Posts: 49
Reputation:
Rep Power: 3
Solved Threads: 0
Here is a whole thread on the matter with many alternatives:
http://www.expertsrt.com/phpBB2/view...d484e1acd201b5
I agree that using a dummy javascript call is best.
http://www.expertsrt.com/phpBB2/view...d484e1acd201b5
I agree that using a dummy javascript call is best.
Site admin at NetBulge.com, a place set out to improve the web 1 good article at a time :)
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- DIV Help! (HTML and CSS)
- Blackout shows Net's fragility (Geeks' Lounge)
- IE and strange UL-tag Phenomena (HTML and CSS)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Javascript Help
- Next Thread: customized right-click menu based on id



Linear Mode