I'm getting very confused reading all the examples about how to use window.postMessage()
with iframes because they all involve one page being notified of activity, like clicks, happening in the other. Or else they only output some text to the console. I just want to get the original iframe embedding working, nothing else.
I have a page at https://subdomain.example.com/page1/
that contains an iframe
like this:
<iframe src="https://example.com/page2/" name="myIframe"></iframe>
Obviously this doesn't work because the origins are different. How do I make it work using postMessage()
? Once the iframe has loaded the pages don't need to communicate or know anything about each other.