不支持

如何判断浏览器是否是什么

function myBrowser() {
      var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
      if (userAgent.indexOf("Firefox") > -1) {
        return ("FF", console.log('Firefox', '是Firefox浏览器'));
      } //判断是否Firefox浏览器
      if (userAgent.indexOf("Chrome") > -1) {
        return ("Chrome", console.log('Chrome', '是Chrome浏览器'));
      }//判断是否Chrome浏览器
      if (!!window.ActiveXObject || "ActiveXObject" in window || (userAgent.indexOf("Trident") > -1)) {
        return ("IE", console.log('IE', '是IE浏览器'));
      }//判断是否IE浏览器
    }
   
 if (myBrowser() == "IE") {
     //如果IE浏览器就怎么操作
    }

 

posted @ 2019-12-07 16:44  骑上我的小摩托  阅读(235)  评论(0编辑  收藏  举报