Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Refresh a site so same part of site is displayed

10:18 am on Jan 5, 2005 (gmt 0)

New User

10+ Year Member

joined:Dec 29, 2004
votes: 0


I have this site inside a frame. This site is bigger then one screen, so I've made it scrollable. Also, the site is set to automatically refresh every now and then. This results in the top of the site beeing displayed, regardless of what part of the site that was displayed before the refresh. How can I store the old location so the same part of the site is displayed after the refresh? I've seen several sites that have this property, so I know it's possible to do.

regards tores

12:59 pm on Jan 5, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2004
votes: 0

Try researching cookie storage, then add a cookie to the user's computer, right before the refresh:

saveCookie(document.body.scrollTop+"~"+document.body.scrollLeft, "scrollPos", 1);

Then, once the page is loaded, you can retrieve the cookie, then get the individual values:

var norm=readCookie("scrollPos").split("~");
window.scroll(norm[1], norm[2]);