views:

136

answers:

7

How can i find what version of browser a user is using and ask him to upgrade it

+2  A: 

You can read the HTTP_USER_AGENT from the Request.ServerVariables

More info here

rdkleine
A: 

JavaScript Browser Detection

Leniel Macaferi
A: 

On the server-side code: Request.Browser returns a HttpBrowserCapabilities instance with all the information you're looking for.

http://msdn.microsoft.com/en-us/library/system.web.httpbrowsercapabilities.aspx

On the client script side (javascript):

http://www.quirksmode.org/js/detect.html

Further to @Nick's comment, the following MSDN post:

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

states:

Browser capabilities indicate whether the browser type in general supports features such as JavaScript, not whether an individual instance of the browser has these features enabled or disabled.

I think version and type of the browser will tend to be fairly consistent.

code4life
Browser Abilities depends on that info being up to date, which often is *not* the case, not at the rate browsers advance.
Nick Craver
+3  A: 

You can perform feature detection using jQuery, like this:

if (!jQuery.support.opacity)
    //Waah waah waah...

You can also check the browser version using jQuery, like this:

if (!jQuery.browser.msie && jQuery.browser.version === 6)
    //Waah waah waah...

However, it should be avoided where possible.

SLaks
+1  A: 

If you are already using a javascript library like jQuery or mootools, you also have those tools at your disposal.

jQuery:

if( $.browser.msie ) {
 // do something
}

mootools:

if (Browser.Engine.trident4) {
  // ie6
}

keep in mind this is usually the wrong thing to rely on. Even the jQuery documentation has a warning that recommends feature detection instead of browser detection.

Dan Heberden
+1  A: 

If it's only about Internet Explorer, you can use conditional comments:

<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->

More info at http://www.quirksmode.org/css/condcom.html

Jasper De Bruijn
A: 
javascript:
  alert(navigator.appVersion)
Jet