Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Top of page link

Status
Not open for further replies.

BDNFLNC

Technical User
May 30, 2002
202
US
OK, I think this one is easy...

In placing a simple "Top of Page" link at the bottom of HTML pages, how do you treat that?

I don't like to use CSS to do it. My boss does it by adding an internal link target to the top of the page.

Is there a wasy to just do a "target=top" or something?

Needs to be compatable in all browsers.

What do you think? -----------------------------------------------
These are endless galaxies which are yours.
You can journey to infinity
through the endless passages of the cosmos.
Even better. This all belongs to you.
This is your mind.
 
The most simple and commonly used is this:
<a href=#top>top</a>

But there's a big complain about #top links: they add a new record to browser history (like any other link). So if a user clicks Back button, it looks like a page jumps without any order to bottom and to top. Also, it adds &quot;#top&quot; to the URL of current page in the address field. That is the reason why many developers stop using #top links.

There's no way to avoid adding new entry into History object when you use links - don't waste your time trying it (many persons tried to do this with no luck).

But there's a way to do it more gently:
<a href=&quot;javascript:scrollTo(0,0)&quot;>Top of Page</a>

Works perfectly in all browsers with JS enabled and doesn't produce any annoying &quot;side effects&quot;.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top