Differentiate IE7 browser and browser in IE7 compatibility mode

后端 未结 5 1529
半阙折子戏
半阙折子戏 2020-11-27 07:00

Can I differentiate if client\'s browser is IE7 or e.g. IE9 in IE7 compatibility mode? I\'m trying to figure out if I can do a JS check on my site which would recognize two

5条回答
  •  长情又很酷
    2020-11-27 07:08

    Here is a fairly bullet-proof check that I did for a large-scale auction site based in San Jose.

    var userAgentString = navigator.userAgent;
    
    if(/MSIE 7\.0/gi.test(userAgentString) && /Trident/gi.test(userAgentString)){
        // compatibility mode
        // .... code goes here ....
    }
    

提交回复
热议问题