程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

js判断当前是pc端、移动端、IE浏览器

发布于2021-03-07 21:37     阅读(1040)     评论(0)     点赞(14)     收藏(5)


是否是pc端、

  function isPc() {
      var userAgentInfo = navigator.userAgent;
      var Agents = ["Android", "iPhone", "symbianOS", "Windows Phone", "iPad", "iPod"]
      var flag = true;
      for (var i = 0; i < Agents.length; i++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
          flag = false
          break
        }
      }
      return flag
    }

是否是IOS

function isIOS() {
      var u = navigator.userAgent;
      if (u.indexOf("Android") > -1 || u.indexOf("Linux") > -1) {
        return false
      } else if (u.indexOf("iPhone") > -1) {
        return true
      } else if (u.indexOf('iPad') > -1) {
        return false
      } else if (u.indexOf('Windows Phone') > -1) {
        return false
      } else {
        return false
      }
    }

是否是IE

 function isIEBrowser() {
      var ua = window.navigator.userAgent
      return !!ua.match(/compatible|MSIE|Trident/i)
    }

是否是移动端

function isDeviceMobile(){
      var ua = window.navigator.userAgent
      return /android|webos|iphone|ipod|balckberry/i.test(ua)
}

是否是IE10浏览器

function isIE10(){
      var ua = window.navigator.userAgent
      return ua.indexOf('MSIE')>=0
}

是否是IE11浏览器

function isIE11(){
      let ua = window.navigator.userAgent.toLocaleLowerCase();
      return ua.indexOf("rv:11")>-1&&ua.indexOf("trident")>-1;
}

原文链接:https://blog.csdn.net/W_Zhulin/article/details/114384724




所属网站分类: 技术文章 > 博客

作者:天使的翅膀

链接:http://www.qianduanheidong.com/blog/article/33532/a5ed471aa21d514491c7/

来源:前端黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

14 0
收藏该文
已收藏

评论内容:(最多支持255个字符)