Check if user is using IE

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

    Using modernizr

    Modernizr.addTest('ie', function () {
        var ua = window.navigator.userAgent;
        var msie = ua.indexOf('MSIE ') > 0;
        var ie11 = ua.indexOf('Trident/') > 0;
        var ie12 = ua.indexOf('Edge/') > 0;
        return msie || ie11 || ie12;
    });
    

提交回复
热议问题