2

window.open(...)用来打开一个全新的窗口(相同的域、相同的子域、相同的目录、相同的所有内容,但不同的 .html 文件)。在子窗口中,我使用它来将消息发送回父窗口:

window.opener.postMessage({status:'ready'}, window.opener.location);

它在 Chrome 和 Firefox 中运行良好……但在 Safari 中却不行。以下是我尝试过的一些无效的替代方案:

window.opener.* // no matter what I put, Safari says .opener is an empty object
window.parent // child refers to self despite different window, same subdomain

如何获得对父窗口的引用,以便可以发回 postMessage(...) 消息?

4

0 回答 0