niche Posted May 29, 2012 Share Posted May 29, 2012 (edited) 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 May 29, 2012 by niche Link to comment Share on other sites More sharing options...
Ingolme Posted May 29, 2012 Share Posted May 29, 2012 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. 1 Link to comment Share on other sites More sharing options...
niche Posted May 29, 2012 Author Share Posted May 29, 2012 What if the refresh is triggered by a form action? Link to comment Share on other sites More sharing options...
Guest So Called Posted May 29, 2012 Share Posted May 29, 2012 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 More sharing options...
niche Posted May 29, 2012 Author Share Posted May 29, 2012 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 More sharing options...
Guest So Called Posted May 29, 2012 Share Posted May 29, 2012 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 More sharing options...
niche Posted May 29, 2012 Author Share Posted May 29, 2012 Thanks So Called and Ingolme. We've taken this topic as far as we can. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 29, 2012 Share Posted May 29, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now