How can i find what version of browser a user is using and ask him to upgrade it
-
4You can use the user agent, which can be spoofed, and alert them...but it depends what you're after, why do they need to upgrade? Is there a feature they need that their current one doesn't support? In that case you should check for that feature's presence.Nick Craver– Nick Craver2010年06月08日 13:16:42 +00:00Commented Jun 8, 2010 at 13:16
-
how can i check whether the user browser supports that feature or not.andrew Sullivan– andrew Sullivan2010年06月08日 13:18:13 +00:00Commented Jun 8, 2010 at 13:18
-
2same: That depends :) Which feature are you looking for? Flash support, opacity support, CSS3 selctors, something else?Nick Craver– Nick Craver2010年06月08日 13:20:12 +00:00Commented Jun 8, 2010 at 13:20
-
@NickCraver in my case, I want to tell them to update from IE7. >:( They don't know that their browser is outdated, and it's not their responsibility to know because they are institutional users who are not allowed to control the software they use; but I can tell them it's outdated, so that they bother their sysadmins. :)ANeves– ANeves2012年11月13日 10:17:27 +00:00Commented Nov 13, 2012 at 10:17
6 Answers 6
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.
Comments
You can read the HTTP_USER_AGENT from the Request.ServerVariables.
In ASP.NET that would be:
Response.Write(HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"]);
Comments
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.
Comments
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
Comments
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.
1 Comment
javascript:
alert(navigator.appVersion)