search

Home  >  Q&A  >  body text

javascript - Determine whether it is a WeChat browser. The same code will invalidate and take effect?

Test address one: (test successful)
http://bbs2.valueonline.cn/we...

Test address two: (test failed)
http://bbs2.valueonline.cn/we...

Determine whether it is the code of WeChat browser:

<script type="text/javascript">
$(function(){
    //判断是否是微信
    var is_weixn=( function(){
        var ua = navigator.userAgent.toLowerCase();
        if(ua.match(/MicroMessenger/i)=="micromessenger"){
            return true;
        }
        else{
            $(".header").removeClass("hide");
            $(".footerMeumBox").hide();
            return false;
        }
    })()
})
</script>

The effect you want to achieve: (the head navigation will not be displayed in the WeChat browser, and the bottom navigation will not be displayed in the ordinary browser)

習慣沉默習慣沉默2868 days ago708

reply all(2)I'll reply

  • 为情所困

    为情所困2017-05-19 10:40:22

    **Are you sure it is the same code?
    Put one code in $(function(){})里,一份不放,当然不放的那一份,在执行的时候找不到$(".footerMeumBox")**

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-19 10:40:22

    Come to install the package. . liveStyle installation package, 2860342721@qq.com,,O(∩_∩)OThank you~(≧▽≦)/~ La La La.

    reply
    0
  • Cancelreply