Forum Moderators: open

Message Too Old, No Replies

Refresh a site so same part of site is displayed

         

tores

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

10+ Year Member



Hi

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

adni18

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

WebmasterWorld Senior Member 10+ Year Member



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);
window.location.reload()

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]);
deleteCookie("scrollPos")