Javascript检测系统信息各个浏览器信息
var sUserAgent = navigator.userAgent;
var fAppVersion = parseFloat(navigator.appVersion);
//比较浏览器版本大小
function compareVersions(sVersion1,sVersion2){
var aVersion1 = sVersion1.split(".");
var aVersion2 = sVersion2.split(".");
if(aVersion1.length>aVersion2.length){
for(var i=0;i<aVersion1.length;i++)
aVersion2.push("0");
}else if(aVersion1.length<aVersion2.length){
for(var i=0;i<aVersion2.length;i++)
aVersion1.push("0");
}
for(var i=0;i<aVersion1.length;i++){
if(aVersion1[i]<aVersion2[i])
return -1;
else if(aVersion1[i]>aVersion2[i])
return 1;
}
return 0;
};
//检测是否Opera浏览器
var isOpera = sUserAgent.indexOf("Opera")>-1;
var isMinOpera4 = isMinOpera5 = isMinOpera6 = isMinOpera7 = isMinOpera7_5 = false;
if(isOpera){
var fOperaVersion;
if(navigator.appName == "Opera"){
fOperaVersion = fAppVersion;
} else {
var reOperaVersion = new RegExp("Opera (http://www.cnblogs.com/eoiioe/admin/file://d+///d+)");
reOperaVersion.test(sUserAgent);
fOperaVersion = parseFloat(RegExp["$1"]);
}
isMinOpera4 = fOperaVersion >= 4;
isMinOpera5 = fOperaVersion >= 5;
isMinOpera6 = fOperaVersion >= 6;
isMinOpera7 = fOperaVersion >= 7;
isMinOpera7_5 = fOperaVersion >= 7.5;
};
//检测是否Safari
var isKHTML = sUserAgent.indexOf("KHTML")>-1
|| sUserAgent.indexOf("Konqueror")>-1
|| sUserAgent.indexOf("AppleWebKit")>-1;
var isMinSafari1 = isMinSafari1_2 = false;
var isMinKonq2_2 = isMinKonq3 = isMinKonq3_1 = isMinKonq3_2 = false;
if(isKHTML){
isSafari = sUserAgent.indexOf("AppleWebKit")>-1;
isKonq = sUserAgent.indexOf("Konqueror")>-1;
if(isSafari){
var reAppleWebKit = new RegExp("AppleWebKit\\/(http://www.cnblogs.com/eoiioe/admin/file://d+(/?:\\.\\d*)?)");
reAppleWebKit.test(sUserAgent);
var fAppleWebKitVersion = parseFloat(RegExp["$1"]);
isMinSafari1 = fAppleWebKitVersion >= 85;
isMinSafari1_2 = fAppleWebKitVersion >= 124;
} else if (isKonq) {
var reKonq = new RegExp("Konqueror\\/(http://www.cnblogs.com/eoiioe/admin/file://d+(/?:\\.\\d+(?:\\.\\d)?)?)");
&n
相关新闻>>
- 发表评论
-
- 最新评论 更多>>