Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does IE 8 navigator.userAgent return MSIE 7.0?

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?

like image 211
Sun Avatar asked Oct 14 '11 23:10

Sun


People also ask

How can you tell if someone is using Internet Explorer?

To detect whether the current browser is Internet Explorer, you can make use of the navigator. userAgent property. The userAgent property returns the value of the user-agent header sent by the browser to the server. It contains information about the name, version, and platform of the browser.

Is browser IE JavaScript?

JavaScript is a browser-based scripting language that is used by web developers to add dynamic interactions and functionalities to web pages. Today, modern web browsers like Internet Explorer 11 have JavaScript enabled by default, allowing users access to enjoy user-interactive experiences on the internet.

How do I know my Internet Explorer browser?

Open Internet Explorer, at the upper right, select the Tools button, and then choose About Internet Explorer. Open Internet Explorer, at the upper right, select the Tools button, and then choose About Internet Explorer.

How do I find my user-agent in Internet Explorer?

Detecting the Internet Explorer browser: The user-agent of the Internet Explorer browser is “MSIE” or “rv:”. Both these values are passed to the indexOf() method to detect this value in the user-agent string and the result of both them are used with the OR operator.


2 Answers

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

like image 50
Maneesh Avatar answered Sep 28 '22 15:09

Maneesh


Are you sure you aren't running in IE7 mode? You can change it somewhere in the Developer settings (F12, I think).

like image 31
Luke Berry Avatar answered Sep 28 '22 16:09

Luke Berry