私人资料库
本博客大部分技术文章,均从网络搜索得来,旨在收集整理技术资料,文章版权归属原作者,由此引起的任何版权问题,与本人无关。

【转自】http://hi.baidu.com/afawwb/blog/item/08fe5923d3ad5b4c935807c1.html

 

代码如下:

 1function CloseWin()
 2{
 3
 4var ua=navigator.userAgent
 5var ie=navigator.appName=="Microsoft Internet Explorer"?true:false
 6if(ie){
 7    var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))))
 8if(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}

19else{
20window.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()">

 

但在IE5.5后就不行了,会弹出警告: 仅在HTML帮助中才有此功能
目的是为了修正一个ActiveX 漏洞。

posted on 2008-10-28 14:47  该显示名称已被其他用户使用  阅读(5498)  评论(0)    收藏  举报