Reload parent while maintaining current scroll position.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brent

    Reload parent while maintaining current scroll position.

    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.l ocation.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

    #2
    Re: Reload parent while maintaining current scroll position.

    On 5$B7n(B14$BF |(B, $B2<8a(B2$B; ~(B58$BJ,(B, Brent <writebr...@gma il.comwrote:
    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.l ocation.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.s crollLeft:windo w.pageXOffset;
    document.Form1. scrolly.value = (document.all)?
    document.body.s crollTop:window .pageYOffset;
    Then use
    window.scrollTo (scrollx, scrolly);
    after the form loads to scroll to the position you saved.

    Hope that helps.

    Roger

    Comment

    • Brent

      #3
      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

      Comment

      Working...