From Iframe to Window:
//The "*" can be a domain name to enhance the security
//The receiver can check the incoming message before executing any funcions.
parent.postMessage('SomeText', '*');
From Window to Iframe:
var frame = document.getElementById('frame');
frame.contentWindow.postMessage('SomeText', '*');
Add Listening for the message events:
window.addEventListener('message', function(event) {
console.log(event.data);
});
Useful Resources:
https://davidwalsh.name/window-iframe
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage




