Check if user is using IE

后端 未结 30 1531
心在旅途
心在旅途 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:57

    I just wanted to check if the browser was IE11 or older, because well, they're crap.

    function isCrappyIE() {
        var ua = window.navigator.userAgent;
        var crappyIE = false;
        var msie = ua.indexOf('MSIE ');
        if (msie > 0) {// IE 10 or older => return version number        
            crappyIE = true;
        }
        var trident = ua.indexOf('Trident/');
        if (trident > 0) {// IE 11 => return version number        
            crappyIE = true;
        }
        return crappyIE;
    }   
    
    if(!isCrappyIE()){console.table('not a crappy browser);}
    

提交回复
热议问题