Iframe-resizer: Failed to execute 'postMessage' error

Created on 17 Sep 2015  Â·  16Comments  Â·  Source: davidjbradshaw/iframe-resizer

The error message indicates an issue with the targetOrigin but we have not set that option so the default should allow all origins right? Is there a specific setting we need to use to enable cross origin posting?

I would prefer to send a link to the page privately - is that possible?

Most helpful comment

The error may occur in Chrome if iframe is not loaded yet. A solution is to call iframeresizer on iframe load event.

All 16 comments

Yep email address is [email protected]

Can you add the error message here.

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided
('XXX') does not match the recipient window's origin ('YYY').

On 18 September 2015 at 17:28, David J. Bradshaw [email protected]
wrote:

Can you add the error message here.

—
Reply to this email directly or view it on GitHub
https://github.com/davidjbradshaw/iframe-resizer/issues/254#issuecomment-141369758
.

Are you manually setting the target?

No. We tried that too but it still failed with the same error.

On 19 Sep 2015, at 1:21 pm, David J. Bradshaw [email protected] wrote:

Are you manually setting the target?

—
Reply to this email directly or view it on GitHub.

The targetOrigin issue seems, to be an issue with Google Chrome, upgrading to this weeks version fixed it for me.

You seem to be getting this problem on your page now.

http://requirejs.org/docs/errors.html#mismatch

We added the protocol to the iframe but are still seeing this error. You
mentioned later that this could be a Chrome issue though so should we
specify the targetOrigin or the checkOrigin:false option? Are there
security concerns with the latter? We are not seeing the error in Firefox
but the iframe isn't resizing.

On 21 September 2015 at 01:32, David J. Bradshaw [email protected]
wrote:

Just had a look at your page. The issue is that the URL in the iFrame tag
does not have a protocol on it and without that it can not workout the
domain to send the message to. You can get around this problem by adding
the checkOrigin:false option. The default is to restrict it the domain
listed in the iFrame.

Interesting issue will have to think of a way to deal with this
automatically in the next release.

—
Reply to this email directly or view it on GitHub
https://github.com/davidjbradshaw/iframe-resizer/issues/254#issuecomment-141819947
.

It's not resizing in Firefox due to an unrelated issue. How are you calling iframeresizer?

var element = document.getElementById('widget-placeholder);
var iframe = document.createElement('iframe');
iframe.id = 'widget123';
iframe.width = '100%';
iframe.src = 'xxx';
iframe.scrolling = 'no';
iframe.frameBorder = 0;
iframe.style.overflow = 'hidden';
element.parentNode.insertBefore(iframe, element);

if (window.jQuery) {
jQuery(iframe).iFrameResize(
{
enablePublicMethods: true
});
} else {
iFrameResize({
enablePublicMethods: true
}, iframe);
}

On 21 September 2015 at 11:11, David J. Bradshaw [email protected]
wrote:

It's not resizing in Firefox due to an unrelated issue. How are you
calling iframeresizer?

—
Reply to this email directly or view it on GitHub
https://github.com/davidjbradshaw/iframe-resizer/issues/254#issuecomment-141872539
.

I'm getting the same error message, but the resize seems to be working fine though (using Google Chrome).

The error may occur in Chrome if iframe is not loaded yet. A solution is to call iframeresizer on iframe load event.

Even after trying out targetOrigin, I am still having CORS issue as I'm trying it on social media embeds. Probably to have an option to skip this function execution?

If you have the error message, but things still work it is due to a bug in Chrome. The error happens when you call iFrameResize before the iFrame has loaded. Their is no way to stop the error in the console, but as soon as the loaded event fires on the iFrame then iFrameResizer resents the message to kick off the resize.

So if things work just ignore the error message.

I got around it with this:

$("#targetframe").on("load", function () {

$('#targetframe').iFrameResize( [{
checkOrigin:false,
log:true,
minHeight:15000,
heightCalculationMethod:'lowestElement'
}] );

});

I figured outs its web security issue. Unless we do a patch with nginx for self hosted URIs. My case was to access contents inside facebook/social embed iframes. I solved that by putting this into a container which resizes through iframe size change. Found a solution recently from google https://developers.google.com/web/updates/2016/10/resizeobserver

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TarsisDragomir picture TarsisDragomir  Â·  5Comments

mouse0270 picture mouse0270  Â·  6Comments

snarfed picture snarfed  Â·  5Comments

russellballestrini picture russellballestrini  Â·  4Comments

frederic117 picture frederic117  Â·  4Comments