Iframe-resizer: Failed to execute 'postMessage' on 'DOMWindow': The target origin (https://....) provided does not match the recipient window's origin ('https://...')

Created on 26 Dec 2016  路  11Comments  路  Source: davidjbradshaw/iframe-resizer

Hi David, I face an issue when using your scripts in sharepoint sites.
Failed to execute 'postMessage' on 'DOMWindow': The target origin (https://....) provided does not match the recipient window's origin ('https://...')
IFrame is in ADFS ( e.g : https://appdev.com/..)
Source one is share point site collection. (e.g. https://spde.com/...)

When I tried with two asp.net application it works great but fails in sharepoint site.

Thanks in advance

question

Most helpful comment

I was having the same error logged to the console, but David's message was clear about what was going on.

Before I had:

<iframe src="https://..." scrolling="no" frameborder="0"></iframe>
<script>iFrameResize()</script>

Now I have:

<iframe src="https://..." scrolling="no" frameborder="0" onload="iFrameResize()"></iframe>

So I'm running iFrameResize() when the iframe loads and the error is gone.

All 11 comments

You get that error if the iFrame has not loaded, you can ignore it if everything still works, as it makes more than one attempt to communicate

I have similar issue, and body of iframe content become empty.

screen shot 2016-12-31 at 12 19 49

screen shot 2016-12-31 at 12 18 04

First page load everything work fine, then after clicking on some link, body become empty and that error is generated, any idea how to fix?

seem that issue is generated by wordpress , since I am embeding a WP site.

thanks

I expect the issue is you need to change the x-Frame-Options http header on wordpress.org, as currently it is set to block iframes.

Just an additional note for anyone else that comes across this... it can also happen if the target site has forgotten to include the content window script file.

I was having the same error logged to the console, but David's message was clear about what was going on.

Before I had:

<iframe src="https://..." scrolling="no" frameborder="0"></iframe>
<script>iFrameResize()</script>

Now I have:

<iframe src="https://..." scrolling="no" frameborder="0" onload="iFrameResize()"></iframe>

So I'm running iFrameResize() when the iframe loads and the error is gone.

Confirmed - the suggestion by @rafaelbiten is working for me too.

Same, with a slow to load embedded website, I had to use @rafaelbiten solution.

That error is because you need to execute into domain configure your Gmail credentials, in my case I executed outside the domain http://localhost

image

Using onload was not enough for me. I had to add a setTimeout wrapper around my resize call and wait a while before attempting the resize.

I expect the issue is you need to change the x-Frame-Options http header on wordpress.org, as currently it is set to block iframes.

If you wind up here and you're using IIS: I had this problem after adding <add name="X-Frame-Options" value="SAMEORIGIN" /> to my web.config. Removing that setting fixes this.

I was facing the same issue, but my issue was caused by redirect from http to https, I was providing in the target iframe the http address of my website URL by providing the URL in https in the iframe resolved the issue.

Was this page helpful?
0 / 5 - 0 ratings