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?
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.
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.
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.
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.
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
Are you sure you aren't running in IE7 mode? You can change it somewhere in the Developer settings (F12, I think).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With