Next, I will briefly introduce a method for judging the mainstream browser type through JS and determining the version number of the mainstream browser type through JS: In today's Internet, there are too many browsers, but most of them are shell-changing, and basically the mainstream browsers are Firefox, Google, IE, and safrai, which are common. Therefore, in our development, sometimes you need to determine the browser you are using and the version you are using, and give some tips based on the returned value. below, I will briefly introduce
How to judge the mainstream browser type through JS and determine the version number of the mainstream browser type through JS:
Var distinguishbrosie = function browserInfo () {var browser = {// IE browser msie: false, // Google chrome: false, // firefox: false, // operabrowser opera: false, // safrai browser safari: false, // name of the browser in use: 'unknown ', // the version number of the browser version: 0}, userAgent = window. navigator. userAgent. toLowerCase (); // use regular expressions to determine if (/(msie | chrome | firefox | opera | netscape) \ D + (\ d [\ d.] *)/. test (userAgent) {browser [RegExp. $1] = true; browser. name = RegExp. $1; browser. version = RegExp. $2;} else if (/version \ D + (\ d [\ d.] *). * safari /. test (userAgent) {browser. safari = true; browser. name = 'safari '; browser. version = RegExp. $2;} return browser;} var browserr = browserInfo (); if (mybi. msie) {console. log (browserr. version);} else {console. log (browserr. name + ''+ browserr. version );}})()
In this way, you can view the current version of the browser in the browser console.