The parent window and the iframe are from 2 separate domains. So in traditional JavaScript these to window should not be able to communicate with each other but thanks to window.postMessage
, this is about to change!!
When clicking on the button you send a message to the parent
window which triggers its background-color
change. As a result, the parent window sendback a message to the iframe
which in turn change the color of its background
.