View Full Version : How to save Scrolling position of the web page ?

Sep 8th, 2007, 03:41 PM
Hi Experts here,
Pls help.

When I Scroll down my web page using vertical scroll bar to some point and when refreshed, I was unable to retain back the scrolled position, instead it always goes to the top part of the page.

How can I retain this scrolled position even after refreshing the page ? a piece of code helps.

Many thanks in advance .

Srinivas Yadav Kota.

Philip M
Sep 8th, 2007, 04:35 PM
What browser are you using? Does this occur after a sort operation?

Have a look at:-


BTW, the time to say "thanks" is afterwards, not beforehand which gives the impression that you take other people's assistance for granted. If you find this response helpful then please use the "Thank You For This Post" button.

Sep 8th, 2007, 04:45 PM
You can use scrollIntoView() (http://developer.mozilla.org/en/docs/DOM:element.scrollIntoView)

Edit: There is also scrollBy() (http://www.w3schools.com/htmldom/met_win_scrollby.asp)and scrollTo() (http://www.w3schools.com/htmldom/met_win_scrollto.asp)....but I don;t remember if those functions work in all browsers...If you used those functions, you'd have to save the vertical/horizontal offset of the page (http://www.howtocreate.co.uk/tutorials/javascript/browserwindow)to a cookie (http://www.w3schools.com/js/js_cookies.asp) or text file, and then retrieve the values on page reload, inserting the values into these functions...