Works cross-domain, but on same domain I get `Invalid target origin 'about:blank' in a call to 'postMessage'.`
See original GitHub issueHey there,
When I first started using this library, I had my local app (my-app.dev
) hosting the content, and I was loading the iframe on another domain (my-test-app.herokuapp.com
) to make sure it worked cross-domain. To my delight, it worked immediately the first time. Yay!
But then I went to embed the iframe on the same domain, and I started getting this error about the targetOrigin being about:blank
:
[iFrameSizer][Host page: ma8a3c1b436e7cd6fdc36f2a160e3c4e4d440ad87-container] [init] Sending msg to iframe[ma8a3c1b436e7cd6fdc36f2a160e3c4e4d440ad87-container] (ma8a3c1b436e7cd6fdc36f2a160e3c4e4d440ad87-container:8:false:true:32:true:true:null:bodyOffset:null:null:0:false:parent:scroll) targetOrigin: about:blank
iframeResizer.min.js:8 Uncaught SyntaxError: Failed to execute 'postMessage' on 'Window': Invalid target origin 'about:blank' in a call to 'postMessage'.
Not sure if this matters, but I’m hosting iframeResizer.min.js on S3, and I’m loading everything with //
(vs. https://
or http://
) to ensure protocols match.
Not sure where to go here, but I’ll keep hacking and report back what I uncover.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Failed to execute 'postMessage' on 'Window': Invalid target ...
The 2nd parameter to postMessage is the "target origin". This is the domain where the page is located, not the name of the...
Read more >Same-origin policy - Web security | MDN
The same-origin policy is a critical security mechanism that restricts how a document or ... Two URLs have the same origin if the...
Read more >Iframe Cross-Domain Tracking In Google Tag Manager
How to track iframes with cross-domain parameters using Google Tag Manager ... Analytics to circumvent the web browser's same-origin policy.
Read more >Window.open() - Web APIs
The Window interface's open() method loads the specified resource into the new or existing browsing context (window, <iframe> or tab) with the specified ......
Read more >Advanced iFrame – WordPress plugin
After 10.000 views/month the iframe is still working but below the iframe a small ... Check if the iframe page and the parent...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah! I was using HelloBar and it embeds an iframe with
src="about:blank"
. I was callingwindow.iframeResize()
and not using the selector option. When I add a class it works:iFrameResize({}, "iframe._my-special-widget-iframe")
Hope this helps someone else!
Thanks for the follow up