子页面(iframe引入的页面)
window.parent.postMessage({eventId:data.eventId},'*');
postMessage的参数:
第一个:要传递的数据,可以是字符串,可以是对象。
第二个:通知给哪个源下面的资源,比如“https://www.sazyj.cn”,则只有父页面在次源下才能接收到这个数据
父页面
window.addEventListener('message', function (e) {
console.log(e.target.data);
},false);