el Dude el Dude - 10 months ago 57
HTML Question

How to remember scroll pos of the `div` to restore it when page is reloaded?

I have

with absolute positioning

<div style:position: absolute; left:50px; overflow: auto; top:200px; right:100px; bottom:25px;>

Above it there is a logo etc.

But if div scrolled down and page is refreshed, the scroll of this div goes at the top of the div.

Is there any method to keep div in previous position after page's refresh?


please read this : How to get scrollbar position with Javascript?

Method 1 and then consider to store a cookie with the scrollbar position.

Method 2 or store the value server side in a visitors table on base of the IP

There is one more funny way.

Method 3 use anchors like <a name="foo"> and send your post action to the URL containing the anchor like this <form action="site.php#foo" ... Its not so exact like the cookie version but it works somehow :))