1. 程式人生 > >微信公眾號裡的H5頁面返回至公眾號首頁

微信公眾號裡的H5頁面返回至公眾號首頁

方法一:關閉瀏覽器模擬達到返回至公眾號首頁的效果

程式碼:

 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 ';  
    } else {  
      window.opener = null;   
      window.open('', '_self', '');  
      window.close();  
    }
  }
}