Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent pages scroll position problem #604

Closed
reubenrd opened this issue Jul 3, 2018 · 11 comments
Closed

Parent pages scroll position problem #604

reubenrd opened this issue Jul 3, 2018 · 11 comments

Comments

@reubenrd
Copy link

reubenrd commented Jul 3, 2018

Hello David

Thank you for creating the iframe resizer script.

I seem to be having the occasional issue with a few of our websites. Once the iframe source has changed to a new source the page position keeps being thrown to the bottom of the page.

Just wondering if anyone else has had an issue like this? Please see example here: https://goo.gl/icHEBF

Please follow through to the last page which requires users details. Any thoughts would be appreciated.

@AndreFabris
Copy link

Hello I have the same problem. It seems it remembers the vertical position of the last loaded page, and new loaded page is displayed in the same position - usually if the new page has no content there it just looks like a white screen.

It makes perfect sense that every time new page loads, vertical position is set to 0. No idea how to do this.

@AlexMeh
Copy link

AlexMeh commented Apr 7, 2019

Same problem here. Anyone figured out how to solve this problem?

@davidjbradshaw Wouldn't it be a great solution to set y-scroll on every new iframe page load to 0?

@davidjbradshaw
Copy link
Owner

You could call scrollTo(0,0) in the onReady event in the page you are loading

@AlexMeh
Copy link

AlexMeh commented Apr 8, 2019

@davidjbradshaw
We already call parentIFrame.scrollTo(0,0), but it passes a negative y-value:
[iFrameSizer][Host page: iFrameResizer0] Reposition requested from iFrame (offset x:8 y:-544)

So the parent site doesn't scroll to top when the iframe page loads a new page.

@davidjbradshaw
Copy link
Owner

davidjbradshaw commented Apr 8, 2019 via email

@AlexMeh
Copy link

AlexMeh commented Apr 9, 2019

@davidjbradshaw No, we simply call:

if ('parentIFrame' in window) {
  parentIFrame.scrollTo(0,0)
}

Can I reach you for private (paid) support? It would be great to have this problem solved.

@davidjbradshaw
Copy link
Owner

The first step would be to put a simple example of the issue online somewhere that I can look at it.

@AndreFabris
Copy link

AndreFabris commented Apr 10, 2019

I used

$(document).ready(function () {
  $("iframe").load(function () {
       $("html, body").animate({scrollTop: 0}, "slow");
  })
})

@sandrab
Copy link

sandrab commented Apr 23, 2019

Try using parentIFrame.scrollTo() within the onReady event, in the page that is loaded in the iframe. Something like this:

window.iFrameResizer = {
  onReady: function () {
    if( 'parentIFrame' in window ) {
      window.parentIFrame.scrollTo(0, 0);
    }
  }
};

This seems to work in my situation. Hope it helps someone!

@davidjbradshaw
Copy link
Owner

davidjbradshaw commented Apr 23, 2019

@sandrab you can reduce your example to this:

window.iFrameResizer = {
  onReady: function () {
     window.parentIFrame.scrollTo(0, 0)
  }
}

@dev-thinks
Copy link

Calling window.parentIFrame.scrollTo(0, 0) on "onReady" event is in-turn calling window.scrollTo(x,y) inside this library; but this seems to have no impact for me in the UI.

But this workaround worked for me:

  1. Passed a message to parent from iframe using window.parentIFrame.sendMessage({...}) when onReady
  2. Capturing that message in parent
  3. Called scrollto in jquery way like - $("#iFrameWrapperDiv")[0].scrollIntoView();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants