How to get browser name and version using JavaScript

Hi friends, In this post I am going to explain about how to get the browser name and there version using simple JavaScript function.

How to get browser name and version using JavaScript by Anil Kumar Panigrahi

How to get browser name and version using JavaScript by Anil Kumar Panigrahi

JavaScript Code

function detectBrowser(){
    var N= navigator.appName;
    var UA= navigator.userAgent;
    var temp;
    var browserVersion= UA.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
    if(browserVersion && (temp= UA.match(/version\/([\.\d]+)/i))!= null)
    browserVersion[2]= temp[1];
    browserVersion= browserVersion? "Browser:"+[browserVersion[1]+"\n Version:"+ browserVersion[2]]: [N, navigator.appVersion,'-?'];
    alert(browserVersion);
   
};

Anil Kumar Panigrahi

With more than 10 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online

Contact : [email protected]

You may also like...

1 Response

  1. Browser Name! I was searching since long.

Leave a Reply

Your email address will not be published. Required fields are marked *