A quick tip: #top

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

A quick tip: #top

Post by phice »

Just noticed this on a few webpages...

Instead of creating a <a name="top"></a> at the top of every single page, you can simply use:

Code: Select all

<a href="javascript:scroll(0,0);"></a>
where you want the "up" link/text placed. Correct me if I'm wrong.
Image Image
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You shouldn't really have an empty anchor tag but at least:

Code: Select all

<a name="top">...</a>
is cross-browser compatible:

Code: Select all

<a href="javascript:scroll(0,0);"></a>
relies on JavaScript being enabled and would be useless in browsers that may not support it (i.e. text to speech browsers).

IMHO, a standards complient HTML solution is 10x better than a JavaScript solution, especially when it is very important to the navigation of the page.

Mac
Post Reply