原创 JS版常见问题(二)兼容版本的无提示关闭窗口!收藏

新一篇: CSDN无限级树数据库版(ASP+ACCESS) | 旧一篇: JS版常见问题(一)层遇到select框时?

论坛里问这个问题的多不胜数,但回答都不尽人意,没有考虑到I浏览器的类型,版本,希望这一文章能帮到大家,有错请指教!本程序ie5,6,ns7下通过

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
<!--
by fason(2003-5-20)
-->
</head>
<body>
<script language="JavaScript">
<!--
function CloseWin()
{
var ua=navigator.userAgent
var ie=navigator.appName=="Microsoft Internet Explorer"?true:false
if(ie){
    var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))))
 if(IEversion< 5.5){
    var str  = '<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">'
    str += '<param name="Command" value="Close"></object>';
    document.body.insertAdjacentHTML("beforeEnd", str);
    document.all.noTipClose.Click();
    }
    else{
    window.opener =null;
    window.close();
    }
}
else{
window.close()
}
}
//-->
</script>
<input type=button value=关闭 onclick="CloseWin()">
</body>
</html>

 

测试:

发表于 @ 2003年06月23日 11:43:00|评论(loading...)|编辑

新一篇: CSDN无限级树数据库版(ASP+ACCESS) | 旧一篇: JS版常见问题(一)层遇到select框时?

评论

#vogts 发表于2004-12-27 17:07:00  IP: 202.107.203.*
我这里测试了,还是不行。。IE5。0的~~`
#etng 发表于2006-07-11 09:32:00  IP: 60.176.240.*
在我看来就这个 window.opener =null;
window.close();重要,其他的不用了吧
#wxlwxlwxlwxl 发表于2006-07-13 15:17:00  IP: 202.206.203.*
以上代码试了,我的ie是5.0的,还是有确认框弹出来.
发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © fason