一段判断浏览器版本的代码,报下标越界
这段代码是在网上直接抄来用的。目的是判断浏览器版本。
在IE下不报错,在chrome和safari下都报错说下标越界
谁能帮忙改改?谢谢
浏览器版本判断?下标越界
<%
Dim Agent,Browser,version,tmpstr
Agent=Request.ServerVariables("HTTP_USER_AGENT")
Agent=Split(Agent,";")
If InStr(Agent(1),"MSIE")>0 Then
Browser="MS Internet Explorer "
version=Trim(Left(Replace(Agent(1),"MSIE",""),6))
ElseIf InStr(Agent(4),"Netscape")>0 Then
Browser="Netscape "
tmpstr=Split(Agent(4),"/")
version=tmpstr(UBound(tmpstr))
ElseIf InStr(Agent(4),"rv:")>0 Then
Browser="Mozilla "
tmpstr=Split(Agent(4),":")
version=tmpstr(UBound(tmpstr))
If InStr(version,")") > 0 Then
tmpstr=Split(version,")")
version=tmpstr(0)
End If
End If
%>
<%
Dim Agent,Browser,version,tmpstr
Agent=Request.ServerVariables("HTTP_USER_AGENT")
If InStr(Agent ,"MSIE")>0 Then
Browser="MS Internet Explorer "
version=Trim(Left(Replace(Agent(1),"MSIE",""),6))
ElseIf InStr(Agent ,"Netscape")>0 Then
Browser="Netscape "
tmpstr=Split(Agent ,"/")
version=tmpstr(UBound(tmpstr))
ElseIf InStr(Agent ,"Chrome")>0 Then
Browser="Chrome "
tmpstr=Split(Agent ,"/")
version=tmpstr(UBound(tmpstr))
ElseIf InStr(Agent ,"Firefox ")>0 Then
Browser="Firefox "
tmpstr=Split(Agent ,"/")
version=tmpstr(UBound(tmpstr))
ElseIf InStr(Agent ,"Safari ")>0 Then
Browser="Safari "
tmpstr=Split(Agent ,"/")
version=tmpstr(UBound(tmpstr))
ElseIf InStr(Agent ,"rv:")>0 Then
Browser="Mozilla "
tmpstr=Split(Agent ,":")
version=tmpstr(UBound(tmpstr))
If InStr(version,")") > 0 Then
tmpstr=Split(version,")")
version=tmpstr(0)
End If
End IF
%>