在IE7中使用window.close();自动关闭窗口时会出现确认关闭的提示.
以下代码可以防止出现这样的提示:
JavaScript代码
<script language="javascript">
openLogin();
function randomNumber(limit){
return Math.floor(Math.random()*limit);
}
function openLogin() {
var loginWidth=718;
var loginHeight=540;
x=(screen.width-loginWidth)/2;
y=(screen.height-loginHeight)/2;
window.resizeTo(loginWidth,loginHeight+20);
window.moveTo(x,y);
var myWin = window.open("http://www.google.com","contactWeb"+randomNumber(10000),"toolbar=0,location=0,status=0,menubar=0,scrollbars=auto,resizable=no,width="+loginWidth+",height="+loginHeight+",left="+x+",top="+y);
window.opener = null; // 关闭IE6、IE7窗口不再提示
window.open('','_top'); // 关闭IE7窗口不再提示
window.close();
}
</script>
以下是在IE6中有效的代码:
JavaScript代码
function DestroySelf()
{
var oMe = window.self;
oMe.opener = window.self;
oMe.close();
}
function LoginSucc(pc)
{
window.open("/portal/Portal.aspx?PassCode="+pc+"","BE_MAIN", "height=" + (window.screen.availHeight - 60) + ", width=" + (window.screen.availWidth - 14) + ", top=0, left=0, menubar=0, location=0, resizable=1, status=1");
setTimeout("DestroySelf()",100);
}