[thelist] window.location to top of page

Christian Heilmann codepo8 at gmail.com
Mon Jul 17 09:38:59 CDT 2006


> Hi all,
>
> I have an application with 2 pages, the query and results page...from
> the results page the user can click on the "back" link( which is at
> the bottom of the results page)to go back to the query page..bt i am
> using frames here so when the user clicks on "back" the user is taken
> to the query page bt to the bottom of the page.....how can i take the
> user to the top of the query page? Is it possible to do so using
> window.location? If so do i have use window.location onload? What
> would be the best way to take the user to the top of the page--
> without adding any extra links like "go to top" etc...

You can add a target to the back link that is in the beginning of the
document. So for example if you have a header in the document with the
results page with the ID "header" you can link back via
results.php#header

If you provide a back link via JavaScript (which is a bad idea, as you
cannot assume JavaScript to be available) you can use
window.location.hash.

-- 
Chris Heilmann
Book: http://www.beginningjavascript.com
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/



More information about the thelist mailing list