当前位置:   article > 正文

js检测浏览器类型以及版本信息_js浏览器版本检查

js浏览器版本检查

js检测浏览器类型以及版本信息

DetectBrowser () {
    const userAgent = window.navigator.userAgent
    const isChrome = userAgent.indexOf('Chrome') > -1 && userAgent.indexOf('Safari') > -1 && userAgent.indexOf('Edge') === -1 && userAgent.indexOf('MetaSr') === -1;
    if(!isChrome){
      this.$message({
          showClose: true,
          message: '您正在使用 非Chrome 浏览器,有些功能暂不支持,可能会影响您的体验,请下载 ',
          type: 'warning',
          center:true,
          duration:0,
          offset:1,
          customClass:"prompt-tip",
          onClose:()=>{
            window.open('https://www.google.cn/chrome/')
          }
        });
      const list = userAgent.split(' ');
      list.forEach((item: any) => {
        if (item.indexOf('Chrome') !== -1){
          const chromeVersion = item.split('/')[1].split('.')[0]  
          if (Number(chromeVersion)<97){
            this.$message({
              showClose: true,
              message: '您正在使用 低版本Chrome 浏览, 有些功能暂不支持,可能会影响您的体验,请下载',
              type: 'warning',
              duration:0,
              offset:1,
              center:true,
              customClass:"prompt-tip",
              onClose:()=>{
                 window.open('https://www.google.cn/chrome/')
              }
            });
          }
          
        }
       
      })
      
    }
  }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/101900
推荐阅读
相关标签
  

闽ICP备14008679号