...

View Full Version : JavaScript link issues



bauhsoj
09-21-2005, 07:02 PM
I recently wrote a page link to take user's to the top of the page using the following:
<a href="#" onClick="scroll(0, 0);">Top</a>

I put the # sign in the href attribute so that the link would look like a standard clickable link.

Are there any known issues with doing this?

Is there a better way to do it, maybe using CSS?

nikkiH
09-21-2005, 07:11 PM
Is the user handicapped and unable to hit their Home key?
Just curious. ;)

bauhsoj
09-21-2005, 07:20 PM
The link sits at the end of a row of other page related functions for convenience sake. Less movement required to move the mouse a couple hundred pixels and click than to move the hand off the mouse to press the Home key. :D

nikkiH
09-21-2005, 07:27 PM
Gotcha.
I'm such a key pressing chick. :D

Anyway, to improve your code, add return false; otherwise the page hiccups.
<a href="#" onClick="scroll(0, 0);return false;">Top</a>

bauhsoj
09-21-2005, 07:51 PM
Gotcha.
I'm such a key pressing chick. :D


Ever read "Don't Make Me Think"? Very good book that focuses on web design and intuitiveness. Most of my customer's already have too much on their minds each day. The more obvious I can make any feature the better. :D



Anyway, to improve your code, add return false; otherwise the page hiccups.
<a href="#" onClick="scroll(0, 0);return false;">Top</a>

Ahh yes, the browser was definately having hiccups.

Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum