npr / responsiveiframe

Responsive IFrames

Home Page:http://npr.github.com/responsiveiframe/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn’t work with nested iframes

supermueller opened this issue · comments

If you have an iframe in an document wicht itself is embedded in an iframe the script fails. The solution is to post the message to the parent window (and not to the top window):

  ResponsiveIframe.prototype.messageParent = function(scrollTop) {
    var h = document.body.offsetHeight;
    h = (scrollTop)? h+'s':h;
    if(parent.postMessage){
      parent.postMessage( h , '*');
    } else {
      window.location.hash = 'h'+h;
    }
  };

Please post a pull request with the solution.

Thanks

I have post a pull request for the first time so I hope I have done it all right.

Done. Thanks!

It's been a pleasure.