完美关闭窗口JS

 1<html>
 2<head>
 3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 4<meta content="Microsoft FrontPage 4.0" name="GENERATOR"/>
 5<meta content="FrontPage.Editor.Document" name="ProgId"/>
 6<title>New Page 1</title>
 7<!--   
 8by fason(2003-5-20)   
 9\-->
10</head>
11<body>
12<script language="JavaScript">   
13<!--   
14function CloseWin()   
15{   
16var ua=navigator.userAgent   
17var ie=navigator.appName=="Microsoft Internet Explorer"?true:false   
18if(ie){   
19var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))))   
20if(IEversion< 5.5){   
21var str = '<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">'   
22str += '<param name="Command" value="Close"></object>';   
23document.body.insertAdjacentHTML("beforeEnd", str);   
24document.all.noTipClose.Click();   
25}   
26else{   
27window.opener =null;   
28window.close();   
29}   
30}   
31else{   
32window.close()   
33}   
34}   
35//-->   
36</script>
37<input onclick="CloseWin()" type="button" value="关闭"/>
38</body>
39</html>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus