Check if user is using IE

后端 未结 30 2075
心在旅途
心在旅途 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 04:47

    Yet another simple (yet human readable) function to detect if the browser is IE or not (ignoring Edge, which isn't bad at all):

    function isIE() {
      var ua = window.navigator.userAgent;
      var msie = ua.indexOf('MSIE '); // IE 10 or older
      var trident = ua.indexOf('Trident/'); //IE 11
    
      return (msie > 0 || trident > 0);
    }
    

提交回复
热议问题