Blog

Detect Browser name and version using javascript

Posted by Dhaval Patel Blogs | .NET 4.5 Oct 16, 2011
How to detect browser name and version using javascript
How to detect  browser   using javascript

  var useragent = navigator.userAgent;
var bName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName;
var pos = useragent.indexOf('MSIE');
if (pos > -1) {
bVer = useragent.substring(pos + 5);
var pos = bVer.indexOf(';');
var bVer = bVer.substring(0,pos);
}
var pos = useragent.indexOf('Opera');
if (pos > -1) {
bVer = useragent.substring(pos + 6);
var pos = bVer.indexOf(' ');
var bVer = bVer.substring(0, pos);
}
if (bName == "Netscape") {
var bVer = useragent.substring(8);
var pos = bVer.indexOf(' ');
var bVer = bVer.substring(0, pos);
}
if (bName == "Netscape" && parseInt(navigator.appVersion) >= 5) {
var pos = useragent.lastIndexOf('/');
var bVer = useragent.substring(pos + 1);
}
document.writeln('<b>Browser Name: </b>' + bName + '<br>');
document.writeln('<b>Browser Version: </b>' + bVer + '<br>')

post comment
     

wht the problem u r facing in above code and link provided by me

Posted by vinay singh Dec 10, 2012

That too Not working for me..

Posted by sarath kumar Dec 10, 2012

Hi sarath kumar please check the below link it's wotking fine.http://www.dotnetpools.com/Article/ArticleDetiail/?articleId=58

Posted by vinay singh Dec 10, 2012

Its not proper And cannot get the deside result. For IE Only its working. Not For FireFox and Chrome.. So just make changes and post for all browsers....

Posted by sarath kumar Dec 10, 2012

This is really nice article check this one alsohttp://www.dotnetpools.com/Article/ArticleDetiail/?articleId=58&title=Jquery%20Code%20To%20Get%20Browser%20Name%20And%20Version%20In%20Asp.Net

Posted by vinay singh Oct 30, 2012
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts