How to store scroll Y position when going one page back

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
BaltarPHP
Forum Newbie
Posts: 10
Joined: Sun May 03, 2009 7:35 am

How to store scroll Y position when going one page back

Post 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?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

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

Post 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?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

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

Post 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).
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
BaltarPHP
Forum Newbie
Posts: 10
Joined: Sun May 03, 2009 7:35 am

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

Post 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?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

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

Post 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
Post Reply