Page 1 of 1

How to store scroll Y position when going one page back

Posted: Mon Aug 10, 2009 9:03 am
by BaltarPHP
Hi. It Should be simple but im a beginner. I have webpage where i can search items. Lets assume the search result gives me a long list. So i scroll down a little and click on an item - a new page opens containing more informatsion about the item. So now then i click back button and it goes back to the search result page - only at the top of the list, not where i scrolled down before so i could continiue scrolling down where i left off. I hope u get the idea what i want so how to programm this?

Re: How to store scroll Y position when going one page back

Posted: Mon Aug 10, 2009 9:58 am
by onion2k
Don't browsers do that automatically when you click the back button? Firefox certainly does. Or do you mean when you click on a "Back to listing" link?

Re: How to store scroll Y position when going one page back

Posted: Mon Aug 10, 2009 11:02 am
by pickle
I don't think that's 100% standard browser behaviour. The only way I can think of doing this is to store the Y co-ordinate in a cookie (set by Javascript).

Re: How to store scroll Y position when going one page back

Posted: Tue Aug 11, 2009 1:14 am
by BaltarPHP
Yes, i ment if i click on the "back to list" link. Ok so how do i store the Y cordinate with javascript cookie?

Re: How to store scroll Y position when going one page back

Posted: Tue Aug 11, 2009 3:16 am
by onion2k
BaltarPHP wrote:Ok so how do i store the Y cordinate with javascript cookie?
jQuery would help a lot..

Find the position: http://docs.jquery.com/CSS/scrollTop
Saving things to a cookie: http://plugins.jquery.com/project/cookie
Scroll to the position: http://plugins.jquery.com/project/ScrollTo