论坛里问这个问题的多不胜数,但回答都不尽人意,没有考虑到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>
测试: