1, in the web development, will often let you determine the current use of the browser and browser that version, according to the browser version to adjust the style of CSS,
To make the Web interface work best for each browser, here's the code to get the current browser:
Copy Code code as follows:
Getbrowserversion:function () {
var agent = Navigator.userAgent.toLowerCase ();
var arr=[];
var browser= "";
var bversion= "";
var verinnum= "";
Ie
if (Agent.indexof ("MSIE") > 0) {
var regstr_ie =/msie [\d.] +;/gi;
Browser= "IE";
Bversion= "" +agent.match (Regstr_ie)
}
Firefox
else if (Agent.indexof ("Firefox") > 0) {
var regstr_ff =/firefox\/[\d.] +/gi;
Browser= "Firefox";
Bversion= "" +agent.match (REGSTR_FF);
}
Chrome
else if (Agent.indexof ("Chrome") > 0) {
var regstr_chrome =/chrome\/[\d.] +/gi;
Browser= "Chrome";
Bversion= "" +agent.match (Regstr_chrome);
}
Safari
else if (Agent.indexof ("Safari") > 0 && agent.indexof ("Chrome") < 0) {
var Regstr_saf =/version\/[\d.] +/gi;
Browser= "Safari";
Bversion= "" +agent.match (REGSTR_SAF);
}
Opera
else if (Agent.indexof ("opera") >=0) {
var Regstr_opera =/version\/[\d.] +/gi;
Browser= "Opera";
Bversion= "" +agent.match (Regstr_opera);
}else{
var browser=navigator.appname;
if (browser== "Netscape") {
var version=agent.split (";");
var trim_version=version[7].replace (/[]/g, "");
var rvstr=trim_version.match (/[\d\.] /g). ToString ();
var rv=rvstr.replace (/[,]/g, "");
BVERSION=RV;
Browser= "IE"
}
}
verinnum= (bversion+ ""). Replace (/[^0-9.] /ig, "");
Arr.push (Browser);
Arr.push (Verinnum);
return arr;
}