作者:情深深锋_433 | 来源:互联网 | 2023-07-26 01:44
判断客户端操作系统:获取客户端操作系统类型functiondetectOS(){varsUserAgentnavigator.userAgent;varisWin(
判断客户端操作系统 :
//获取客户端操作系统类型
function detectOS()
{
var sUserAgent = navigator.userAgent;
var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh");
if(isMac) return "Mac";
var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
if(isUnix) return "Unix";
var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
if(isLinux) return "Linux";
if(isWin)
{
var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1;
if(isWin2K) return "Win2000";
var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1;
if(isWinXP) return "WinXP";
var isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1;
if(isWin2003) return "Win2003";
}
return "None";
}
判断浏览器类型:
var Browser_Name //浏览器名称
var Browser_Version; //浏览器版本识别数
var Browser_Agent=navigator.userAgent;
//浏览器语言版本
var language = (navigator.appName == 'Netscape'?navigator.language:navigator.browserLanguage);
if(Browser_Agent.indexOf("MSIE")>0) Browser_Type = "IE";
else if(Browser_Agent.indexOf("Firefox")>0) Browser_Type = "Firefox";
else if(Browser_Agent.indexOf("Safari")>0) Browser_Type = "Safari";
else if(Browser_Agent.indexOf("Camino")>0) Browser_Type = "Camino";
else if(Browser_Agent.indexOf("Konqueror")>0) Browser_Type = "Konqueror";
else if(Browser_Agent.indexOf("Chrome")>0) Browser_Type = "Chrome";
else Browser_Type = "Other";
if (language.indexOf('en') > -1) Browser_Lang = '英文';
else if (language.indexOf('zh') > -1) Browser_Lang = '中文';
if (Browser_Type == 'IE')
{
if(navigator.appVersion.match(/8./i)=='8.')
Browser_Version = '8';
if(navigator.appVersion.match(/7./i)=='7.')
Browser_Version = '7';
else if(navigator.appVersion.match(/6./i)=='6.')
Browser_Version = '6';
}else
{
Browser_Version = navigator.appVersion;
}
ASP获取客户端浏览器和操作系统信息的两个函数
功能:获取客户端浏览器和操作系统信息
描述:用Request.ServerVariables("Http_User_Agent")
获取客户端浏览器类型的函数:
Private Function Browser()
Info=Request.ServerVariables("Http_User_Agent") '在这里初始化了Info,在实际应用中可以作为其他变量赋值,得到客户端浏览器类型的有关数据
If InStr(Info,"MSIE")>0 Then
Browser="Internet Explorer"
ElseIf InStr(Info,"Firefox")>0 Then
Browser="Firefox"
ElseIf InStr(Info,"Chrome")>0 Then
Browser="Chrome"
ElseIf InStr(Info,"Opera")>0 Then
Browser="Opera"
ElseIf InStr(Info,"Safari")>0 Then
Browser="Safari"
Else
Browser="未知的浏览器!"
End If
End Function
获取客户端操作系统函数:
Private Function System()
Info=Request.ServerVariables("Http_User_Agent") '获取客户端操作系统信息数据
If InStr(Info,"NT 5.1")>0 Then
System="Windows XP"
ElseIf InStr(Info,"NT 5.0")>0 Then
System="Windows 2000"
ElseIf InStr(Info,"NT 4")>0 Then
System="Windows NT"
ElseIf InStr(Info,"98")>0 Then
System="Windows 98"
ElseIf InStr(Info,"Me")>0 Then
System="Windows Me"
ElseIf InStr(Info,"95")>0 Then
System="Windows 95"
ElseIf InStr(Info,"2003")>0 Then
System="Windows 2003"
Else
System="未知的操作系统!"
End If
End Function