iframe-resizer: window.parentIFrame no longer being set?

Hi David, I’ve been using (and loving!) iframe-resizer for about a year now. Suddenly I’ve noticed something really weird: it looks like window.parentIFrame isn’t being set on the parent window at all – not even on your example page. Only noticed this because an if('parentIFrame' in window) type check has begun failing, without there being any code change on my side. This seems to be happening from anywhere I test, so I don’t think it’s a local issue either. Am I crazy?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Had same problem with missing window.parentIFrame. Found out, that I needed to set enablePublicMethods: true for iFrameResize in the parent window like this:.

iFrameResize({ log : true, checkOrigin: false, enablePublicMethods : true, messageCallback : function(messageData){ if('Reload' === messageData.message){ location.href = location.href; } } });

Since v3 there is no need to set that option.

You also don’t need the messageCallback.

Also what I noticed is that you need to wait for the iframe to fully load and resized before window.parentIFrame is available. So, either you need to call it from inside readyCallback or for testing purposes you could call it after a timeout to make sure the iframe has loaded.

My bad, please ignore my previous comment. I was calling window.parentIFrame before it was loaded. It works as expected when calling from inside readyCallback.