1<body>
2 <iframe id="site2-frame" src="http://www.mysite2.com/index.php"></iframe>
3</body>
4
1var frame = document.getElementById('site2-frame');
2
3frame.contentWindow.postMessage('Something something something', '*');
4
1var input = document.getElementById('input-field');
2
3window.addEventListener('message', function(e) {
4 // Check the origin, accept messages only if they are from YOUR site!
5 if (/^http\:\/\/www\.mysite1\.com/.test(e.origin)) {
6 input.value = e.data;
7 // This will be 'Something something something'
8 }
9});
10