判断低版本浏览器

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jbguo/article/details/82802243

// 获取火狐版本

 getBrowserInfo: function () {
    var agent = navigator.userAgent.toLowerCase();
    var regStrff = /firefox\/[\d.]+/gi;
    if (agent.indexOf('firefox') > 0) {
      return agent.match(regStrff);
    }
  },

// 判断是否是ie

  isIE: function () { //ie?
    if (!!window.ActiveXObject || "ActiveXObject" in window) {
      return true;
    } else {
      return false;
    }
  },

// 判断低版本浏览器

  getIsBrowserTip: function () {
    var isBrowserTip = false;
    var browser = utils.getBrowserInfo();
    var verinfo = (browser + '').replace(/[^0-9.]/ig, '');
    var theUA = window.navigator.userAgent.toLowerCase();
    var ieBrowser = utils.isIE();
    // if (ieBrowser) {
    //   isBrowserTip = true;
    // }
    if ((theUA.match(/msie\s\d+/) && theUA.match(/msie\s\d+/)[0]) || (theUA.match(/trident\s?\d+/) && theUA.match(/trident\s?\d+/)[0])) {
      var ieVersion = theUA.match(/msie\s\d+/)[0].match(/\d+/)[0] || theUA.match(/trident\s?\d+/)[0];
      if (ieVersion < 10 || verinfo < '56') {
        isBrowserTip = true;
      }
    }
    return isBrowserTip;
  },

猜你喜欢

转载自blog.csdn.net/jbguo/article/details/82802243