Fix window.close failure

function f_close(){
  if(typeof(WeixinJSBridge)! ="undefined"){
    WeixinJSBridge.call('closeWindow');
  }else{
    if (navigator.userAgent.indexOf("MSIE") > 0) {  
      if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {  
        window.opener = null; window.close();  
      } else {  
        window.open(' '.'_top'); window.top.close(); }}else if (navigator.userAgent.indexOf("Firefox") > 0) {  
      window.location.href = 'about:blank ';  
      //window.history.go(-2);  
    } else {  
      window.opener = null;   
      window.open(' '.'_self'.' ');  
      window.close(); }}Copy the code

2. For personal problems, both IOS and Android phones can be turned off (the order of the two can not be changed)


setTimeout(function(){
  // This can turn off android phones
  document.addEventListener('WeixinJSBridgeReady'.function(){ WeixinJSBridge.call('closeWindow'); }, false);
  // This phone can turn off ios
  WeixinJSBridge.call('closeWindow');
}, 1000)

Copy the code