【转自】http://hi.baidu.com/afawwb/blog/item/08fe5923d3ad5b4c935807c1.html
代码如下:
1
function CloseWin()
2
{
3
4
var ua=navigator.userAgent
5
var ie=navigator.appName=="Microsoft Internet Explorer"?true:false
6
if(ie){
7
var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))))
8
if(IEversion< 5.5){
9
var str = '<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">'
10
str += '<param name="Command" value="Close"></object>';
11
document.body.insertAdjacentHTML("beforeEnd", str);
12
document.all.noTipClose.Click();
13
}
14
else{
15
window.opener =null;
16
window.close();
17
}
18
}
19
else{
20
window.close()
21
}
function CloseWin()2
{3

4
var ua=navigator.userAgent5
var ie=navigator.appName=="Microsoft Internet Explorer"?true:false6
if(ie){7
var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))))8
if(IEversion< 5.5){9
var str = '<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">'10
str += '<param name="Command" value="Close"></object>';11
document.body.insertAdjacentHTML("beforeEnd", str);12
document.all.noTipClose.Click();13
}14
else{15
window.opener =null;16
window.close();17
}18
}19
else{20
window.close()21
}
以前有单独的代码:
1
<OBJECT id="xboj" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" VIEWASTEXT>
2
<PARAM name="Command" value="Close">
3
</OBJECT>
4
<input type=button value="close" onclick="xboj.HHClick()">
<OBJECT id="xboj" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" VIEWASTEXT> 2
<PARAM name="Command" value="Close"> 3
</OBJECT> 4
<input type=button value="close" onclick="xboj.HHClick()">
但在IE5.5后就不行了,会弹出警告: 仅在HTML帮助中才有此功能
目的是为了修正一个ActiveX 漏洞。



浙公网安备 33010602011771号