Home > Net >  How to store the item currently scrolled to in the URL?
How to store the item currently scrolled to in the URL?

Time:11-09

So I have a page that displays a list of 100 items. How would I be able to store the item that is being scrolled to in the URL, so that the user can control which item is scroll to in the URL?

www.site.com/inventory?scroll_position=67

CodePudding user response:

Include a tag at the text you wish to scroll to:

<a name="scroll_position=67"></a>

The url needs to read: www.myawesomesite.com/inventory#67

When the page loads run the following javascript:

function scrollTo(hash)
{
 location.hash='#' hash;
}
  • Related