Copy code code as follows:
Get Browser name and version information
function AppInfo () {
var browser = {
Msie:false, Firefox:false, Opera:false, Safari:false,
Chrome:false, Netscape:false, appname: ' Unknown ', version:0
},
useragent = Window.navigator.userAgent.toLowerCase ();
if (/(Msie|firefox|opera|chrome|netscape) \d+ (\d[\d.) *)/.test (useragent)) {
BROWSER[REGEXP.$1] = true;
Browser.appname = regexp.$1;
Browser.version = regexp.$2;
else if (/version\d+ (\d[\d.) *). *safari/.test (useragent)) {//Safari
Browser.safari = true;
Browser.appname = ' Safari ';
Browser.version = regexp.$2;
}
return browser;
}
Call Example
var myos = AppInfo ();
If the current browser is IE, pop-up browser version, otherwise pop-up current browser name and version
if (Myos.msie) {
alert (myos.version);
} else {
Alert (Myos.appname + myos.version);
}
Copy Code code as follows:
function Getos ()
{
var osobject = "";
if (Navigator.userAgent.indexOf ("MSIE") >0) {
return "MSIE";
}
if (Isfirefox=navigator.useragent.indexof ("Firefox") >0) {
return "Firefox";
}
if (Issafari=navigator.useragent.indexof ("Safari") >0) {
return "Safari";
}
if (Iscamino=navigator.useragent.indexof ("Camino") >0) {
return "Camino";
}
if (Ismozilla=navigator.useragent.indexof ("gecko/") >0) {
return "Gecko";
}
}