Here's a few things to consider:
- We do not usually want a link to return the caret to the top of the page.
- If using a click event handler, place a hash in the href attribute and a return false; as the final code for the onClick attribute; ensure any preceding function calls can be interpreted and executed or the return false may never be reached.
- Alternatively, use another tag (not an anchor tag) and its onClick attribute.
a (without href) (no underline)
a href="wwww.mysite.com" (normal link)
a href="" (opens containing folder in IE (when run without a web server); scrolls to top of page in FF)
a href="#" (scrolls to top of page)
a href="top" (scrolls to top of page)
a href="null" (no underline)
* a href="#bookmark" (works if a name is defined immediately above)
a onclick="return false;" (without href) (no underline)
* a href="" onclick="return false;" (works)
* a href="#" onclick="return false;" (works)
* a href="#" onclick="myOnClickFunc (); return false;" (works)
* styled span (works but doesn't "select" on click or change color on visit)
* = A preferred way to do nothing links
Very helpful, thanks :)ReplyDelete