Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a link to nowhere 2

Status
Not open for further replies.

Geates

Programmer
Aug 25, 2009
1,566
US
How do I create a link that goes nowhere and does nothing (from a href perspective)? The purpose is simply to provide clickable text that will toggle a div's display between 'none' and 'block' via a js function.

I have tried href="" which works, but changes focus to another window after being clicked. (Kind of like alt+tab). I have also tried href="#" but this takes you back to the top of the page.

If there is no way to do it through an anchor link, I can fabricate one with a span but would prefer the prior

Code:
<span style="text-decoration: underline;" onClick="toggleDisplay('text1');">Link</span>

Any suggestions?

-Geates
[/code]


"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Hi

Tried to stop the link's default behavior ?
HTML:
[b]<a[/b] [maroon]href[/maroon][teal]=[/teal][green][i]""[/i][/green] [maroon]onclick[/maroon][teal]=[/teal][green][i]"toggleDisplay('text1');[highlight]return false[/highlight]"[/i][/green][b]>[/b]Link[b]</a>[/b]

Feherke.
 
that work as expected. thanks!

-Geate

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
you could also use the javascript protocol
Code:
<a href="javascript:myfunction();">link text</a>

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
I like that format better.

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top