1. 程式人生 > >web頁在微信中訪問增加遮罩層 右上角彈出在瀏覽器中打開

web頁在微信中訪問增加遮罩層 右上角彈出在瀏覽器中打開

osi nis scrip div ttr auto nav csdn img

https://blog.csdn.net/zgsdzczh/article/details/79744838

web頁在微信中訪問增加遮罩層 右上角彈出在瀏覽器中打開

  1. <style type="text/css">
  2. * {
  3. margin: 0;
  4. padding: 0;
  5. }
  6. a {
  7. text-decoration: none;
  8. }
  9. img {
  10. max-width: 100%;
  11. height: auto;
  12. }
  13. .weixin-tip {
  14. display: none;
  15. position: fixed;
  16. left: 0;
  17. top: 0;
  18. bottom: 0;
  19. background: rgba(0, 0, 0, 0.8);
  20. filter: alpha(opacity = 80);
  21. height: 100%;
  22. width: 100%;
  23. z-index: 100;
  24. }
  25. .weixin-tip p {
  26. text-align: center;
  27. margin-top: 10%;
  28. padding: 0 5%;
  29. }
  30. </style>
  1. <div class="weixin-tip">
  2. <p>
  3. <img src="images/tip.png" alt="在瀏覽器打開" />
  4. </p>
  5. </div>
  1. <script>
  2. $(window).on("load", function() {
  3. var winHeight = $(window).height();
  4. function is_weixin() {
  5. var ua = navigator.userAgent.toLowerCase();
  6. if (ua.match(/MicroMessenger/i) == "micromessenger") {
  7. return true;
  8. } else {
  9. return false;
  10. }
  11. }
  12. var isWeixin = is_weixin();
  13. if (isWeixin) {
  14. $(".weixin-tip").css("height", winHeight);
  15. $(".weixin-tip").show();
  16. }
  17. })
  18. </script>

DEMO下載地址

還有另外一個參考案例:

file:///C:/Users/Administrator/Desktop/449/449/index.html

web頁在微信中訪問增加遮罩層 右上角彈出在瀏覽器中打開