我正在执行 window.opener.postMessage('a=1','*')
,当前窗口是通过 window.open
打开的。
window.opener
的 console.log
确实显示了正确的窗口,但我没有看到消息进入开启器。
我正在做 $(window).on( 'message', handleMessage );
其中 handleMessage 有一个 console.log
知道它被击中了。我已经为跨 iframe 通信做了好几次,并希望为我的新窗口实现同样的事情。
最佳答案
来自 caniuse :
Partial support in IE8-9 refers to only working in frames/iframes (not other tabs/windows).
是的,你可以,但浏览器支持更有限。
关于javascript - 我可以向 window.opener 发送消息吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18623161/