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