2

Chrome seems to remember the last vertical scroll position of most websites when reloading the page or going back to it from another page. However, it's not working on my site.

The site is a fairly simple server-side generated layout, not using any client side rendering at all.

What could be causing such a behaviour?

  • 1
    What cache control mechanisms do you use? – Stephen Ostermiller Jun 22 '17 at 16:59
  • "going back to it from another page" - by hitting the [Back] button. Simply going "back to it" by following a link won't retain the vertical position. I would have said this must be dependent on the client-side browser cache (since you say you have no JS? Or just no client-side rendering?) - if you disable all client-side caching then I don't see how the browser can "remember" where the vertical position was? However, having tried to reproduce this behaviour myself by supposedly disabling caching, I cannot reproduce it - the browser always remembers the vertical position?! – DocRoot Jun 23 '17 at 11:57
  • Please add the HTTP response headers that your page is returning. – DocRoot Jun 23 '17 at 11:58
4

In my case was a css issue at body (Firefox, Safari not affected by the problem):

overflow: auto;

After I remove it, it seems to work well.

  • For me, it was overflow-x: hidden; (which we added to avoid IE from showing a horizontal scrollbar). – Yngve Høiseth Feb 18 '20 at 10:37
1

I am searching for the solution for the same problem. As you said, It happens when html code generates in JS. Browser doesn't find where to go (because html codes hadn't been generated yet.) and it goes 0,0.

I solved the problem with the min-height. I added a min-height value to the body code in CSS.

And, this is my first post in StackExchange. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.