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

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 fason 的 blog

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

 

测试:

本文关键:关闭 无提示
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top