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

Created on 26 Oct 2016  Â·  12Comments  Â·  Source: davidjbradshaw/iframe-resizer

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?

All 12 comments

Strange, just tried the example page in Chrome 53 and 54 without problem. Do you just see the issue in one browser?

I'm seeing this issue both across browsers and machines. So far I've tested locally on two different Macs using Chrome 54 and Firefox 49, and via BrowserStack using different versions of Chrome, IE and Firefox on both a Mac and a PC, but to no avail: every time I give the console window.parentIFrame, I get undefined. Meanwhile, window.iFrameResize initialises correctly.

I noticed the issue because a client told me a behaviour was no longer triggering, so they seem to be seeing the same issue.

I'm experiencing the same issue

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.

@davidjbradshaw I'm sorry to pester you with this, but as a sanity check, could you confirm that only window.iFrameResize initializes at https://utopia.de/nachhaltige-stellenangebote/, while window.parentIFrame doesn't?

I'm not @davidjbradshaw but I'm following this thread as I've had a similar issue. I can confirm that window.parentIFrame returns as undefined in the console on the link you posted.

@shaynasymons thank you for checking that! Given that there could be any other kind of mistake on my side in the environment I linked to, do you see the same behaviour on David's example page?

@ggsp Yes, it returns as undefined there, as well. It also returns as undefined in my project on every page unless I call it in the readyCallback function.

You need to test it in the iFrame, not on the parent page.

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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anlambert picture anlambert  Â·  6Comments

frederic117 picture frederic117  Â·  4Comments

russellballestrini picture russellballestrini  Â·  4Comments

mcodev1 picture mcodev1  Â·  9Comments

lukashanssondn picture lukashanssondn  Â·  7Comments