h5页面判断微信端用浏览器打开代码

<div class="weixin-tip">
        <p>
            <img src="img/live_weixin.png" alt="微信打开"/>
        </p>
    </div>
<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();
            }

             var u = navigator.userAgent;
                var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
                var isiOS = !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
                //alert('是否是Android:'+isAndroid);
                //alert('是否是iOS:'+isiOS);
                 if(isAndroid){
                     $("#box2").clone().attr("id","box3").insertBefore($('#box1'));
                     $("#box2").hide();
                     $("#box3").css("margin-bottom","10px");
                 }
             })
    </script>
    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%;}

原文地址:https://www.cnblogs.com/junwu/p/6423861.html