Html link returns to where you were on page?

Janck Fan

New member
Hey,
So I have this webpage and there is an index page and other pages (of course). The index page is really big and it takes a lot of scrolling to see all of the content. Within the content there are links to other pages of the website. When you click the link it goes that that page and there is a "back to home" button that takes you back to the index page, but it takes you to the top of the index page. I would like it to take you to where you were when you left the index page in the first place.
So if you are halfway down the index page, you click a link, then click "back to home" you go back to halfway down the index page. Is there a way to do this with HTML, CSS, or Javascript?
 
This would most definitely be a JavaScript question I don't know how you do it but thought I would push you to the right direction.

How ever with HTML you can have in page jump links. These HTML links when clicked just jump to a different part of the same page. Saves the user scrolling.

I know sometimes people want to use there own method as a way of learning but if you do wish to look into this here you are.

http://w3schools.com/html/html_links.asp

Look under the header "HTML Links - The name Attribute"

Good luck
 
Learn how to use cookies. Update it with scroll position whenever you click a link on the index page, and check whether there is a cookie set whenever the index page loads.

There are some different properties to determine your scroll position, like window.pageYOffset and document.documentElement.scrollTop. I'm not sure which one works best these days.

Using named anchors in the "back to home" button would be complicated, and it won't even affect users who press the browser's back button instead.
 
Back
Top