How to get browser name and version using JavaScript

in JavaScript / 1 Comment

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);
   
};

PHP Web developer with 6 years of experience in Web Development, Integrating web designing, Testing and Deployment , and developed medium level to large scale websites using PHP , and as blogger maintaining technical blog Contact : php.anil@gmail.com

Discussion 1 Comment

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>