Detecting IE version not considering compatibility mode

ぃ、小莉子 提交于 2019-12-10 19:27:31

问题


I'm trying to figure out if it's possible to detect what version of IE you are using, and not your document-mode. It can be server or client-code (doesn't matter), I just need to know what version of IE the user has installed.


回答1:


It could be detected in both, by examining the User-Agent string. Note that browsers can spoof their UA string, but this is rarer now than in the past. See this article on MSDN for older UA strings.

Note also that IE8 sends a different UA string in Compatibility mode and in Standards mode (see this and this - both are IE8, although the former says MSIE 7.0).

See this for a long list of UA strings - note that you should be looking for a pattern, not exact match, as installed software will modify the UA string.

IE9 has some new UA string thing - see the IEBlog for details.

To summarize (and borrow from @EricLaw's comment):

  • no Trident in UA string - check the MSIE [0-9].0 string for version
  • Trident/4.0 - IE 8, version in MSIE is not relevant
  • Trident/5.0 - IE 9


来源:https://stackoverflow.com/questions/4539280/detecting-ie-version-not-considering-compatibility-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!