[thelist] Automatically scroll down to anchor

Christian Heilmann lists at onlinetools.org
Wed Feb 2 18:53:02 CST 2005

Christian Heilmann wrote:

> bernardo escalona wrote:
>> Hello web gurus,
>> Can someone show me by example how to force a page to scroll down to 
>> a specific part of the page (anchor) as soon as the page is loaded?
>> Im inserting a short javascript like this:
>> window.location="#foo"
>> but its not working quite right.
>> Will appreciate any pointers.
> You need to use location.hash:
> http://www.susqu.edu/webcentral/javascript/js5.cfm
Which is for javascript only, normally it is enough to add the hash to 
the url as explained by Michael. The hash method will fail on browsers 
without Javascript, you could use a backend script aswell, checking for 
a # in  the current location and adding it if needed.

More information about the thelist mailing list