How to open a web address on WeChat and open it in a browser

When using WeChat to open the URL, you cannot open commonly used downloading software, mobile APP, etc. in WeChat. All kinds of WeChat circulating on the Internet open the download link, and the WeChat update basically fails. A common method is to pop up a mask to prompt the user to open in a new browser window, and no longer need to worry about how to update WeChat.

Directly judge the WeChat ua. If it is opened in the WeChat built-in browser, a mask will pop up to prompt the user to open the download in the browser without adding a close button. In this way, the sub-user can only open it in the browser and can download the application directly.

Insert picture description here

CSS code

<style type="text/css">
  *{
    
    
    margin:0; 
    padding:0;
  }
  a{
    
    
    text-decoration: none;
  }
  img{
    
    
    max-width: 100%; 
    height: auto;
  }
  .weixin-tip{
    
    
    display: none; 
    position: fixed; 
    left:0; 
    top:0; 
    bottom:0; 
    background: rgba(0,0,0,0.8); 
    filter:alpha(opacity=80); 
    height: 100%; 
    width: 100%; 
    z-index: 100;
  }
  .weixin-tip p{
    
    
    text-align: center; 
    margin-top: 10%; 
    padding:0 5%;
  }
</style>

HTML code

<div class="weixin-tip">
  <p>
    <img src="live_weixin.png" alt="微信打开"/>
  </p>
</div>

JS code

<script type="text/javascript">
  $(window).on("load",function(){
    
    
    var winHeight = $(window).height();
    function is_weixin() {
    
    
      var ua = navigator.userAgent.toLowerCase();
      if (ua.match(/MicroMessenger/i) == "micromessenger") {
    
    
        return true;
      } else {
    
    
        return false;
      }
    }
    var isWeixin = is_weixin();
    if(isWeixin){
    
    
      $(".weixin-tip").css("height",winHeight);
      $(".weixin-tip").show();
    }
  })
</script>

Guess you like

Origin blog.csdn.net/JTJT_/article/details/108618875