https://github.com/biqing/MessengerJS
父页面
var messenger = new Messenger('tiebaIframe', 'tiebaGame');
var iframe1 = document.getElementById('iframe1');
messenger.addTarget(iframe1.contentWindow, 'iframe1');
window.addEventListener('click', function() {
messenger.send('hi');
});
或
iframe.onload = function(){
messenger.send('hi');
}
子页面
/* messenger初始化 /
var messenger = new Messenger('gameIframe', 'tiebaGame');
messenger.addTarget(window.parent, 'tiebaIframe');
console.log(window.parent,1)
/ 接收信息 */
messenger.listen(function(data){
console.log(data);
});