vue项目判断非google浏览器打开,强制调用google方法

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <meta name=renderer content=webkit>
  <link rel="shortcut icon" href="<%= webpackConfig.output.publicPath %>favicon.ico">
  <link rel="stylesheet" href="./public.css">
  <title>测试测试</title>
  <style>
    .error {
      display: none;
      width: 100%;
      text-align: center;
      margin-top: 50px;
    }
  </style>

</head>

<body>
  <noscript>
    <strong>Were sorry but app2 doesnt work properly without JavaScript enabled. Please enable it to continue.</strong>
  </noscript>
  <div name="error" id="error" class="error">
    <h3>
      提示:请使用Chrome打开
    </h3>
    <h3>
      ******系统访问地址:http://*****************
    </h3>
    <h3>
      Chrome下载地址:http://www.baidu.com
    </h3>
  </div>
  <div id="app"></div>
  <!-- built files will be auto injected -->

  <script type="text/javascript">
    function IEVersion() {
      var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
      var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
      var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器
      var isIE11 = userAgent.indexOf(Trident) > -1 && userAgent.indexOf("rv:11.0") > -1;
      if(isIE) {
        var reIE = new RegExp("MSIE (\d+\.\d+);");
        reIE.test(userAgent);
        var fIEVersion = parseFloat(RegExp["$1"]);
        if(fIEVersion == 7) {
          return 7;
        } else if(fIEVersion == 8) {
          return 8;
        } else if(fIEVersion == 9) {
          return 9;
        } else if(fIEVersion == 10) {
          return 10;
        } else {
          return 6;//IE版本<=7
        }
      } else if(isEdge) {
        return edge;//edge
      } else if(isIE11) {
        return 11; //IE11
      }else{
        return -1;//不是ie浏览器
      }
    }
    function openGoogle() {
      if (IEVersion() == -1) {
        return false
      }
      try{
        var osh = new ActiveXObject("WScript.Shell");
        var p_app_path = osh.RegRead(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe\);
        var oShell = new ActiveXObject("Shell.Application");
        var website = http://**********/; // 项目实际地址
        oShell.ShellExecute(p_app_path, website, "", "open", "1");
        window.location.href = "http://********/tips2.html" // 服务器更目录放置的展示页面
      } catch (e) {
        // var ele = document.getElementsByName(error)[0]
        // ele.style.display = block
        window.location.href = "http://**********/tips.html" // 服务器更目录放置的展示页面
      }
    }
    openGoogle()
  </script>
</body>


</html>
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><meta name=renderer content=webkit><link rel="shortcut icon" href=/favicon.ico><link rel=stylesheet href=./public.css><title>*****系统</title><style>.error {
      width: 100%;
      text-align: center;
      margin-top: 50px;
      line-height: 30px;
    }</style></head>
    <body>
      <div name=error id=error class=error>
        <h3>提示:请使用Chrome(谷歌浏览器)打开</h3>
        <h3>****系统访问地址:http://*******/</h3>
      </div>
  </body></html>

// tips.html
经验分享 程序员 微信小程序 职场和发展