| Author |
Browser detect and IE
|
elizabeth thomas
Greenhorn
Joined: May 12, 2003
Posts: 7
|
|
Hi, I am using the following simple code to detect the browser version. When I run the code in IE 6.0, I am getting the browser version as "4". Can anyone explains me what the robelm is?? browser_version= parseFloat(navigator.appVersion); browser_type = navigator.appName; if (browser_type == "Microsoft Internet Explorer" && (browser_version >= 4)) { alert ("You appear to be using Microsoft Internet Explorer: " + browser_version); } else if (browser_type == "Netscape" && (browser_version >= 4)) { alert ("You appear to be using Netscape: " + browser_version); }
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50674
|
|
Yes, that is what it does. If you take a look at the value of the navigator.userAgent attribute you will see why it does what it does (but that doesn't mean it actually makes sense). You will note however, that the correct browser version number is embedded in the userAgent string. This is what you should be using to perform browser determination. You can use regular expression processing to parse the version number out of the userAgent string. hth, bear [ May 14, 2003: Message edited by: Bear Bibeault ]
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
elizabeth thomas
Greenhorn
Joined: May 12, 2003
Posts: 7
|
|
|
Thank You bear. It worked
|
 |
Manish Hatwalne
Ranch Hand
Joined: Sep 22, 2001
Posts: 2559
|
|
Actually, in most cases a better idea is to detect property supported (such as getElementById) by the browser rather than to detect a browser name. Few brosers like Opera can fake a user agent string. - Manish
|
 |
 |
|
|
subject: Browser detect and IE
|
|
|