window.close()不出现提示框的方法

当我们使用window.close()时经常会出现一个提示框,提示我们是否关闭。

我们可以用如下方法,来去除提示框从而增加客户体验。

 

Html代码   收藏代码
  1. function Close(){  
  2.     var ua = navigator.userAgent;  
  3.     var ie = navigator.appName == "Microsoft Internet Explorer"?true:false;  
  4.     if(ie){  
  5.         var IEversion = parseFloat(ua.substring(ua.indexOf("MSIE")+5,ua.indexOf(";",ua.indexOf("MSIE"))));  
  6.         alert(IEversion);  
  7.         if(IEversion < 5.5){  
  8.             var str = "<object id = 'noTipClose' classid='clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11'>";  
  9.             str += "<param name='Command' value='Close'/></object>";  
  10.             document.body.insertAdjacentHTML("beforeEnd",str);  
  11.             document.all.noTipClose.Click();  
  12.         }else{  
  13.             window.opener = null;  
  14.             window.open('','_self','');  
  15.             window.close();  
  16.         }  
  17.     }else{  
  18.         widow.close();  
  19.     }  
  20.     }  

 

猜你喜欢

转载自bigdragon.iteye.com/blog/2261124