Jump to content

best way maintain position in a scroll upon refresh SOLVED with thanks in the last post


niche
 Share

Recommended Posts

What's the best way maintain position in a scroll upon refresh? I'm currently using anchors inside divs, but the page usually has some "jump" as the targeted div is sent to the top of the viewable page on refresh. If there's a better way what is it?

Edited by niche
Link to comment
Share on other sites

Firefox maintains the position on the page automatically for me. There's no real way to detect if the page has been refreshed or not, so you can't remember the scroll position.

  • Like 1
Link to comment
Share on other sites

Guest So Called
What if the refresh is triggered by a form action?
Why would it matter? Or use AJAX if it does matter. I use #anchors when I face a similar problem. The page loads, then it snaps to the #anchor when it's done loading. I've assumed that's just the way that it works, and that I can use AJAX if I want to improve on it.
Link to comment
Share on other sites

Is there something specific you have in mind in AJAX or are you referring to the general advantage of updating a page client side?

Link to comment
Share on other sites

Guest So Called

I'm no AJAX expert. I can barely tell you what the acronym stands for. But with AJAX in place you can update the page without reloading. At least as far as I know. AJAX is (as I'm sure you know) not just client side. Server and client work together to update the page without a total refresh.

Link to comment
Share on other sites

Thanks So Called and Ingolme. We've taken this topic as far as we can.

Link to comment
Share on other sites

An extreme way would be to have an onscroll event handler that stores the scroll position in a cookie every time they scroll. I'm not sure if that would make scrolling choppy, it might. On a refresh you can check to see if the current page has a scroll position and jump to it if the cookie is new enough.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...