Why are messages not being sent to the iframe?
The page has an iframe with src
http://child.com/widget/. A message is sent to it from the parent (the domain is different, let it be
On the iframe side, the message is received using
iframe.contentWindow.postMessage("confidential information string", "http://child.com/widget/")
window.addEventListener ('message', foo). But when sent using the above method, messages do not come.
I've tried changing the targetOrigin in postMessage to
http://child.combut that doesn't help. Messages are received only if you specify
"*", which is unsafe, because the message contains confidential data.
From the documentation I read, everything should work correctly, however, it doesn't.
To place the code, please use CodePen or similar tool. Thanks you!