Reload parent while maintaining current scroll position.

B

Brent

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 name> anchors, 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
 
B

BlueSky

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 name> anchors, 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
 
B

Brent

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top