在a页面打开一个窗口b并监听message事件
$("#loginIn").click(function() {
window.open('b.html','_blank','width=670,height=350,left=300,top=100')
})
window.addEventListener('message', function(ev) {
console.log(ev.data)
},false)
b页面
window.parent.postMessage('success','http://'+window.location.host)
然后console出来的data为什么没有这个success字符串??
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
ev.data输出的内容明显不对,正确的值应该为success而不是一个对象;把window.parent改为
window.opener试试,父窗口和打开窗口是两个概念