silversurfer5150 — 2011-09-14T05:39:00-04:00 — #1
A problem popped up this morning that I have always known about but never had to deal with until now. What if I need to display an anchor link which goes nowhere, I have two choices right?
I appreciate any advice
ralphm — 2011-09-14T06:35:50-04:00 — #2
I think there are lots of debates over this. An alternative you could try is
<p><a href="#me" id="me" onclick="return false;">Something</a></p>
The ideal would be to have the JS out of the HTML altogether, but I'm not quite sure how to write that. (It's a job for the JS forum. )
PS: the real problem here is having a link that does nothing with JS off. Ideally, users without JS shouldn't be left with a dead link. If that's the case, it suggests there's a better solution.
silversurfer5150 — 2011-09-14T06:41:09-04:00 — #3
Thanks Ralph that's interesting, so basically you are targeting the anchor to itself so that you don't get the page scrolling.
I guess you could just use jquery :
That way you are targeting the link with the id of me without having to have any inline scripting.
blain — 2011-09-14T07:46:03-04:00 — #4
Then you should do something like