微信內打開網頁提示請在瀏覽器打開頁面效果代碼


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>請在微信外打開此鏈接</title>
</head>
<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>
<body>
    <div class="weixin-tip">
        <p>
          <img src="https://s1.ax1x.com/2020/07/09/UmomPf.png" alt="微信打開"/>
        </p>
      </div>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<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();
      }else{
          window.location.href="/";
      }
    })
</script>
</body>
</html>

不多啰嗦,直接上源碼。由於微信封域名實在厲害,不得已的辦法,卻是很有效的辦法!效果自己測試

如果代碼中的外鏈圖片地址失效,這里有備用下載地址:

點我下載

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM