asp vbscript 检测客户端浏览器和操作系统(也可以易于升级到ASP.NET)

dim Info,SystemName,BrowserName,ipdress
 Info=Request.ServerVariables("Http_User_Agent")

'涂聚文 2009/09/30 缔友计算机信息技术有限公司 捷为工作室 =其次:用Request.ServerVariables("Http_User_Agent")=
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 598; .NET CLR 2.0.50727; CIBA; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; InfoPath.1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; InfoPath.2)
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.13) Gecko/2009080717 Firefox/3.0.13
 'Opera/9.80 (Windows NT 5.1; U; zh-cn) Presto/2.2.15 Version/10.01
 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 QQDownload/1.7
'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 QQDownload/1.7
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.27 Safari/532.0
'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9.1
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080219 Firefox/2.0.0.12 Navigator/9.0.0.6
Function Browser(Info)
Info=Request.ServerVariables("Http_User_Agent") '在这里初始化了Info,在实际应用中可以作为其他变量赋值
'Response.Write Info & "<p>"
If InStr(Info,"MSIE 9")>0 Then
Browser="Internet Explorer 9"
If InStr(Info,"MSIE 8")>0 Then
Browser="Internet Explorer 8"
ElseIf InStr(Info,"MSIE 7")>0 Then
Browser="Internet Explorer 7"
ElseIf InStr(Info,"MSIE 6")>0 Then
Browser="Internet Explorer 6"
ElseIf InStr(Info,"MSIE 5.5")>0 Then
Browser="Internet Explorer 5.5"
ElseIf InStr(Info,"MSIE 5.0")>0 Then
Browser="Internet Explorer 5.0"
ElseIf InStr(Info,"MSIE 4")>0 Then
Browser="Internet Explorer 4.0"
ElseIf InStr(Info,"Opera")>0 Then
Browser="Opera"
ElseIf InStr(Info,"Firefox")>0 and InStr(Info,"Chrome/3")=0 and InStr(Info,"Safari/5")=0 and InStr(Info,"Navigator")=0 Then
Browser="Firefox"
ElseIf InStr(Info,"Chrome")>0 and InStr(Info,"Safari")>0 Then
Browser="Chrome"
ElseIf InStr(Info,"Safari")>0 Then
Browser="Safari"
'Navigator
ElseIf InStr(Info,"Navigator")>0 and InStr(Info,"Firefox")>0 Then
Browser="Navigator"
Else
Browser="未知的浏览器"
End if
'Response.Write "'涂聚文 2009/09/30 缔友计算机信息技术有限公司 捷为工作室您的浏览器是:"&Browser&"<p>"
BrowserName=Browser
End Function

Function System(Info)
Info=Request.ServerVariables("Http_User_Agent")
If InStr(Info,"Windows NT 6.1")>0 Then
System="Windows7/2008R2"
ElseIf InStr(Info,"Windows NT 6.0")>0 Then
System="Vista/2008"
ElseIf InStr(Info,"Windows NT 5.2")>0 Then
System="Windows 2003"
ElseIf InStr(Info,"Windows NT 5.1")>0 Then
System="Windows XP"
ElseIf InStr(Info,"Windows NT 5.0")>0 Then
System="Windows 2000"
ElseIf InStr(Info,"Windows 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,"Mac")>0 Then
System="Mac"
ElseIf InStr(Info,"Unix")>0 Then
System="Unix"
ElseIf InStr(Info,"Linux")>0 Then
System="Linux"
ElseIf InStr(Info,"SunOS")>0 Then
System="SunOS"
Else
System="未知的操作系统"
End if
'Response.Write "您的操作系统是:"&System&"<p>"
 SystemName=System
End Function

BrowserName= Browser(Info)
SystemName= System(Info)
ipdress=Request.ServerVariables("REMOTE_ADDR")

 

你可能感兴趣的:(VBScript)