main.php 有
<a href="redirect.php" target="_blank">open new window</a>
然后redirect.php有
top.top.location.href='http://xx.com/index.html';
当我单击链接打开新窗口时,redirect.php 在新窗口中打开并重定向http://xx.com/index.html。问题在这里:在此页面中,javascript 代码强制关闭此新窗口并将主窗口重定向到http://xx.com/index.html。
javascript 代码http://xx.com/index.html有:
try{
if(opener) {
opener.location.href=this.location.href;
top.close();
}
}
如何防止主页被子窗口关闭?