我使用打开了一个弹出窗口window.open()
。我现在想要的是用户能够单击这个新窗口中的两个链接之一:“允许”或“不允许”。
当用户单击这些链接之一时,“弹出”窗口应该关闭,并返回“允许”或“不允许”或类似的内容,true
/false
就可以了,到父窗口。
是否可以?如果是这样,怎么办?
Code:
var authWindow = window.open('auth.php', 'authWindow', 'options...');
然后里面只有 2 个锚点auth.php
?
在调用(父)窗口中添加这样的JS代码:
function HandlePopupResult(result) {
alert("result of popup is: " + result);
}
在子窗口代码中添加以下内容:
function CloseMySelf(sender) {
try {
window.opener.HandlePopupResult(sender.getAttribute("result"));
}
catch (err) {}
window.close();
return false;
}
并有这样的链接来关闭弹出窗口:
<a href="#" result="allow" onclick="return CloseMySelf(this);">Allow</a>
<a href="#" result="disallow" onclick="return CloseMySelf(this);">Don't Allow</a>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)