美文网首页
javascript判断是不是PC端打开

javascript判断是不是PC端打开

作者: Author_z | 来源:发表于2017-07-03 16:12 被阅读0次

首先我们需要了解一下Navigator.userAgent


image.png
image.png

windows的就不贴了
如果我们直接判断userAgent是不是就好了???
先贴代码试试咯!!

//获取useragent
var UserAgent = navigator.userAgent;
var systemInfo = UserAgent.split('(')[1].split(";")[0];
if (systemInfo === "iPhone" || systemInfo === "Linux"){
        console.log('phone')
}else{
        window.location.href = '/isweb'
    }

只能想到这么多了,如果有大牛有更好的办法请告知!跪谢!!

相关文章

网友评论

      本文标题:javascript判断是不是PC端打开

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