点击按钮在新窗口中打开新页面,自动关闭旧窗口。IE7以上版本必须加此方法 window.open('', '_self', ''); 否则还会弹出确认窗。另外此方法如果在onblur事件中触发,旧窗口能自动关闭,但是新窗口打不开。
代码
<html>
<body >
<input type="button" value="jump" onclick="jump()">
</body>
<SCRIPT LANGUAGE="JavaScript">
function jump()
{
window.open('aa.html','_blank','toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no');
window.opener = null;
window.open('', '_self', '');
window.close();
}
</SCRIPT>
</HTML>
<body >
<input type="button" value="jump" onclick="jump()">
</body>
<SCRIPT LANGUAGE="JavaScript">
function jump()
{
window.open('aa.html','_blank','toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no');
window.opener = null;
window.open('', '_self', '');
window.close();
}
</SCRIPT>
</HTML>