美文网首页
判断移动端,pc端,微信浏览器,非微信浏览器

判断移动端,pc端,微信浏览器,非微信浏览器

作者: 不会写代码的机器人 | 来源:发表于2020-04-22 15:44 被阅读0次
function(){
    var ua = window.navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
      /* 这是微信浏览器 */
      if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
        alert("微信移动端")
        console.log("微信移动端")
      } else {
        // pc
        console.log("微信pc端")
        alert("微信pc端")
      }
    } else {
      /* 不是微信浏览器,H5支付 */
      if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
        console.log("h5移动端")
        alert("h5移动端")
      } else {
        // pc
        alert("h5pc端")
        console.log("h5pc端")
      }
    }
}

相关文章

网友评论

      本文标题:判断移动端,pc端,微信浏览器,非微信浏览器

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