美文网首页
判断当前是否为PC端方法

判断当前是否为PC端方法

作者: Fortune_Cookie | 来源:发表于2018-12-03 21:47 被阅读0次
        <script type="text/javascript">
            function initView(){
                var ua = navigator.userAgent.toLowerCase();
                var mobile = /mobile/gi.test(ua);
                isPC = !mobile;
                if(isPC){
                    console.log('当前为PC')
                }
                else
                {
                    console.log('当前不是PC')
                }
            }
            initView();
        </script>
    

    效果截图:


    Chrome设置为IPhone6 用电脑浏览器打开时

    相关文章

      网友评论

          本文标题:判断当前是否为PC端方法

          本文链接:https://www.haomeiwen.com/subject/eynucqtx.html