Check if user is using IE

后端 未结 30 2127
心在旅途
心在旅途 2020-11-22 04:34

I am calling a function like the one below by click on divs with a certain class.

Is there a way I can check when starting the function if a user is using Internet

30条回答
  •  甜味超标
    2020-11-22 05:08

    This returns true for any version of Internet Explorer:

    function isIE(userAgent) {
      userAgent = userAgent || navigator.userAgent;
      return userAgent.indexOf("MSIE ") > -1 || userAgent.indexOf("Trident/") > -1 || userAgent.indexOf("Edge/") > -1;
    }
    

    The userAgent parameter is optional and it defaults to the browser's user agent.

提交回复
热议问题