弹出窗口在关闭时将数据返回给父级
我使用 window.open()
打开了一个弹出窗口。我现在想要的是用户能够单击这个新窗口中的两个链接之一:“允许”或“不允许”。
当用户单击其中一个链接时,“弹出”窗口应关闭,并返回“允许”或“不允许”或类似的内容,true
/false 就可以了,到父窗口。
是否可以?如果是这样,怎么办?
代码:
var authWindow = window.open('auth.php', 'authWindow', 'options...');
那么 auth.php
内只有 2 个锚点?
I've got a popup window opened using window.open()
. What I want now is for a user to be able to click one of 2 links within this new window: "Allow" or "Don't Allow".
When a user clicks one of those links the 'popup' window should close, and return either "allow" or "don't allow" or something along those lines, true
/false
would do, to the parent window.
Is it possible? If so, how?
Code:
var authWindow = window.open('auth.php', 'authWindow', 'options...');
Then just 2 anchors inside auth.php
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 window.opener 来实现此目的。
you can use
window.opener
for this.在调用(父)窗口中添加这样的JS代码:
在子窗口代码中添加这样的:
并有这样的链接来关闭弹出窗口:
In the calling (parent) window add such JS code:
In the child window code add this:
And have such links to close the popup: