Scroll to named hyperlink on page load
Posted on 2004-09-14
How do I cause the web page to scroll to a named hyperlink on page load?
I have an area on the page where a user uses a listbox to select sub-categories until they reach the desired level. Above this listbox I have a "bread crumb trail" of hyperlinks to the higher levels:
CurrentLevel : Rooty > Level 1 > Level 2 (Root, Level 1, Level 2 are hyperlinks back to this page)
[Listbox of subcategories for current selection] (subcategories for Level 2 in this example).
Since this "control" is towards the bottom of the page, when a user selects either the links, or a selection in the list box the page reloads and the page is positioned at the top.
I can get the hyperlinks to work by appending a #category to the link and adding a <a name=category></a> tag.
But how do I accomplish something similar when an entry in the listbox is selected (the listbox has AutoPostBack=true)