View Full Version : is using <span> the only way of getting rid of jumpiness for an onclick

05-28-2004, 03:41 PM
Let me elaborate. I am a newbie at this stuff, so I've just been using the <a> tag to trigger my javascripts. But one thing that i hate about that is the jumpiness it creates. I was told by somebody that I really should be using <span>, but then I lose the nifty pointer change and :hover :visited, effects. I know there is a work around, but I was really just trying to avoid anymore code. When I use <span> that sort of jumpiness which is caused by the href="#" goes away, but I was wondering if there was a way for me to keep using <a> and also avoid that jumpiness?

By jumpiness I mean evertime I trigger a javascript it throws me back to the top of the page. Sometimes maybe I want to stay at the bottom of the page.

Let me actually clarify, the jumpiness is caused by the href="#" not necessarily the <a> tag, but the href is also what gives my words that cool :hover effect, so the problem remains: How do I keep the roll-over effect without the jumpiness.

05-28-2004, 03:48 PM
The function that processes <a> onclick event should return false:

<a href="#" onclick="return processOnclick()">
function processOnclick()
{ ...
return false;
That said, it takes ~10 lines of code to teach IE do hover and active with elements other than <a>: www.vladdy.net/demos/IEPseudoClassesFix.html
You waste more bytes using <a> instead of <span>