Why does IE 8 navigator.userAgent return MSIE 7.0?

Sun picture Sun · Oct 15, 2011 · Viewed 11.8k times · Source

I am trying to implement a browser support feature on my webpage. For Firefox 3.6 it is working fine, but for some reason IE 8's userAgent is returning a wrong value.

Here is the scenario, when I run a 'local' javascript code on IE8, navigator.userAgent returns correct information (MSIE 8.0). But when I run this script on a server, it returns MSIE 7.0 on an IE 8 browser.

Any ideas?

Answer

Maneesh picture Maneesh · Dec 5, 2012

You need to check Trident token too.

Trident token

When the F12 developer tools are used to change the browser mode of Internet Explorer, the version token of the user-agent string is modified to appear so that the browser appears to be an earlier version. This is done to allow browser specific content to be served to Internet Explorer and is usually necessary only when websites have not been updated to reflect current versions of the browser.

When this happens, a Trident token is added to the user-agent string. This token includes a version number that enables you to identify the version of the browser, regardless of the current browser mode.

MORE : http://msdn.microsoft.com/en-us/library/ms537503.aspx