Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you detect the version of a browser?

I've been searching around for code that would let me detect if the user visiting the website has Firefox 3 or 4. All I have found is code to detect the type of browser but not the version.

How can I detect the version of a browser like this?

like image 563
odle Avatar asked May 06 '11 20:05

odle


People also ask

How do I find my browser version?

Launch the Edge Browser on computer PC, and go to Edge help location in the address bar: edge://settings/help. It will display the official build and version on the browser screen.

How can you find out the version information of the client's browser?

To detect the browser version on the client machine, your script can analyze the value of navigator. appVersion or navigator. userAgent.

How do I know what browser I am using JavaScript?

To detect user browser information we use the navigator. userAgent property. And then we match with the browser name to identify the user browser. Now call this JS function on page load, and this will display the user browser name on page load.


1 Answers

You can see what the browser says, and use that information for logging or testing multiple browsers.

navigator.sayswho= (function(){     var ua= navigator.userAgent;     var tem;      var M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];     if(/trident/i.test(M[1])){         tem=  /\brv[ :]+(\d+)/g.exec(ua) || [];         return 'IE '+(tem[1] || '');     }     if(M[1]=== 'Chrome'){         tem= ua.match(/\b(OPR|Edge)\/(\d+)/);         if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera');     }     M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];     if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);     return M.join(' '); })();  console.log(navigator.sayswho); // outputs: `Chrome 62`
like image 122
kennebec Avatar answered Oct 21 '22 04:10

kennebec