我有parent window (opener)
和child (popup)
---------- --------------
| | | |
| parent | -----> opens popup | child |
| | | |
----------- --------------
假设,在父页面中,我有 js 功能hello()
为了让孩子在孩子窗口关闭时调用父母的 hello() 并传递一个参数,我可以这样做,
window.close();
window.opener.hello(someArgument);
这将关闭窗口并调用父级的 hello();
但是如果我不想在子页面中有代码 window.opener.hello() 怎么办?我的意思是我希望代码仅在父页面中
我能想到的一件事是:
有些父母知道孩子何时关闭(事件监听器???在 js 中不确定)但在这种情况下如何接收参数?(即从孩子那里回来的一些数据)