This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes navigator.userAgent wrong IE version detection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "navigator.userAgent wrong IE version detection" Watch "navigator.userAgent wrong IE version detection" New topic
Author

navigator.userAgent wrong IE version detection

Liwuen Chew
Greenhorn

Joined: Mar 11, 2010
Posts: 24
Greetings!
Hope someone can help me with this. I'm running a JS function which uses the navigator.userAgent string to get the browser's main information (Among this there is the browser version).
My problem is that, for some reason, navigator.userAgent return version 7 as the actual version when the script is run in IE9. Tried with different browsers and all of them work fine, is just IE the one that is having detection issues.
Can you please help me onto getting the reason why it detects wrongly the IE version? Thanks in advance!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Your browser is running in IE7 mode in IE9. It is right, your sniffing is wrong.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

Browser sniffing is generally regarded as a poor practice -- rather, features detection is preferred.

For what reason as you sniffing the browser?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: navigator.userAgent wrong IE version detection
 
Similar Threads
IE7 and XMLHttpRequest
How to find the browser version?
Graphics Help
Design question
IE 8 compatibility Issue