如当前要打开的窗口为about.htm
<script language =javascript >
function openwin()
{
newwin=window.open('about.htm','login','location=no,toolbar=no,status=yes,resizable=no,scrollbars=no,menubar=no,directories=no')
newwin.moveTo(-3,-3);
newwin.resizeTo(screen.availWidth+6, screen.availHeight+6);
window.opener=null; //opener是一个容器,它代表当前窗口
window.close();
}
</script>
function openwin()
{
newwin=window.open('about.htm','login','location=no,toolbar=no,status=yes,resizable=no,scrollbars=no,menubar=no,directories=no')
newwin.moveTo(-3,-3);
newwin.resizeTo(screen.availWidth+6, screen.availHeight+6);
window.opener=null; //opener是一个容器,它代表当前窗口
window.close();
}
</script>
第2种方法
把关闭老窗口的语句写在新打开的窗口的onload事件中,这样比较保险!即新窗口已经保证打开了,再关闭老窗口
老窗口的代码
<script language =javascript >
function openwin()
{
newwin=window.open('about.htm','login','location=no,toolbar=no,status=yes,resizable=no,scrollbars=no,menubar=no,directories=no')
newwin.moveTo(-3,-3);
newwin.resizeTo(screen.availWidth+6, screen.availHeight+6);
}
</script>
<script language =javascript >
function openwin()
{
newwin=window.open('about.htm','login','location=no,toolbar=no,status=yes,resizable=no,scrollbars=no,menubar=no,directories=no')
newwin.moveTo(-3,-3);
newwin.resizeTo(screen.availWidth+6, screen.availHeight+6);
}
</script>
新窗口代码
<script language =javascript >
function CloseOld()
{
window.opener.opener=null;
window.opener.close();
}
CloseOld();
</script>
window.opener代表老窗口
也就是窗口初始化时执行关闭老窗口!
<script language =javascript >
function CloseOld()
{
window.opener.opener=null;
window.opener.close();
}
CloseOld();
</script>
window.opener代表老窗口
也就是窗口初始化时执行关闭老窗口!