JSFiddle - React, Tailwind, and code Playground
by Darby Rathbone
HTML
<button id='newwindow'>new window</button>
JavaScript
function callback(e) {
console.log(e);
}
document.getElementById('newwindow').addEventListener('click', function (e) {
var winTwo = window.open('', 'connect', 'width=820,height=450');
var a = document.createElement('script');
a.innerHTML='(function(){addEventListener("message",function(e){e.source.postMessage("something",e.source.location.href);document.body.appendChild(document.createTextNode(e.data));});}())';
winTwo.document.head.appendChild(a);
winTwo.postMessage('test', location.href);
console.dir(winTwo);
});
addEventListener('message',function(e){console.log(e.data);});