Connecting Tech Pros Worldwide Forums | Help | Site Map

Reload parent while maintaining current scroll position.

Brent
Guest
 
Posts: n/a
#1: Jun 27 '08
I have a child page opened with a simple open() statement. I'd like to
be able to refresh the parent page and keep the current scroll
position. (If I do an "F5" refresh on IE, for instance, the page will
return to the last position it had.) Is there any "easy" way to
accomplish this?

I've been using

window.opener.location.reload();

but this returns the page to the top. I also tried setting up a bunch
of <a nameanchors, and scroll to these, but this scrolling places
the anchor at the top of the page, which isn't always where the scroll
was before.

Thanks for any pointers.

--Brent

BlueSky
Guest
 
Posts: n/a
#2: Jun 27 '08

re: Reload parent while maintaining current scroll position.


On 5$B7n(B14$BF|(B, $B2<8a(B2$B;~(B58$BJ,(B, Brent <writebr...@gmail.comwrote:
Quote:
I have a child page opened with a simple open() statement. I'd like to
be able to refresh the parent page and keep the current scroll
position. (If I do an "F5" refresh on IE, for instance, the page will
return to the last position it had.) Is there any "easy" way to
accomplish this?
>
I've been using
>
window.opener.location.reload();
>
but this returns the page to the top. I also tried setting up a bunch
of <a nameanchors, and scroll to these, but this scrolling places
the anchor at the top of the page, which isn't always where the scroll
was before.
>
Thanks for any pointers.
>
--Brent
Hi Brent,

Try saving the scroll position in some hidden fields before the form
gets unloaded,
like this:
document.Form1.scrollx.value = (document.all)?
document.body.scrollLeft:window.pageXOffset;
document.Form1.scrolly.value = (document.all)?
document.body.scrollTop:window.pageYOffset;
Then use
window.scrollTo(scrollx, scrolly);
after the form loads to scroll to the position you saved.

Hope that helps.

Roger
Brent
Guest
 
Posts: n/a
#3: Jun 27 '08

re: Reload parent while maintaining current scroll position.


Thanks for your help, Roger. I ended up simply writing the values one-
by-one to the parent page, rather than refreshing to grab them. This
solution seemed to satisfy the client the most.

--Brent
Closed Thread