webForumDet fria alternativet

Identifiera Opera?

2 svar · 169 visningar · startad av Peeer

PeeerMedlem sedan mars 20025 907 inlägg
#1

Hej!
Använder det nedstående script (av Pace) för att avgöra vilken browser besökaren använder. Men det verkar ha lite problem med att känna igen Opera. Jag provade med Opera 6.0, Mozilla/4.0 (compatible; MSIE 5.0; Windows XP) Opera 6.0 [sv], men det identifierades som IE 5. Vad göra?

Function getBrowser()
	Dim Browser, ua
	
	ua = Request.ServerVariables("HTTP_USER_AGENT")
	
	If Instr(ua, "MSIE") Then
		If Instr(ua, "MSIE 6.") Then
			Browser = "Microsoft Internet Explorer 6.x"
		ElseIf Instr(ua, "MSIE 5.") Then
			Browser = "Microsoft Internet Explorer 5.x"
		ElseIf Instr(ua, "MSIE 4.") Then
			Browser = "Microsoft Internet Explorer 4.x"
		ElseIf Instr(ua, "MSIE 3.") Then
			Browser = "Microsoft Internet Explorer 3.x"
			If Instr(ua, "MSIE 3.02") Then
				Browser = "Microsoft Internet Explorer 3.02"
			End If
		Else
			Browser = "Microsoft Internet Explorer"
		End If
	ElseIf Instr(ua, "Mozilla") and Instr(ua, "compatible") = 0 Then
		If Instr(ua, "Netscape6") Then
			Browser = "Netscape Navigator 6.x"
		ElseIf Instr(ua, "Mozilla/4") Then
			Browser = "Netscape Navigator 4.x"
		ElseIf Instr(ua, "Mozilla/3") Then
			Browser = "Netscape Navigator 3.x"
		Else
			Browser = "Netscape Navigator"
		End If
	ElseIf Instr(ua, "Opera") Then
		Browser = "Opera"
	End If
	
	getBrowser = Browser
End Function
@ndersMedlem sedan juni 200032 969 inlägg
#2

Flytta upp opera-kollen överst.

Function getBrowser()
	Dim Browser, ua
	
	ua = Request.ServerVariables("HTTP_USER_AGENT")
	
	If Instr(ua, "Opera") Then
		Browser = "Opera"	
	ElseIf Instr(ua, "MSIE") Then
		If Instr(ua, "MSIE 6.") Then
			Browser = "Microsoft Internet Explorer 6.x"
		ElseIf Instr(ua, "MSIE 5.") Then
			Browser = "Microsoft Internet Explorer 5.x"
		ElseIf Instr(ua, "MSIE 4.") Then
			Browser = "Microsoft Internet Explorer 4.x"
		ElseIf Instr(ua, "MSIE 3.") Then
			Browser = "Microsoft Internet Explorer 3.x"
			If Instr(ua, "MSIE 3.02") Then
				Browser = "Microsoft Internet Explorer 3.02"
			End If
		Else
			Browser = "Microsoft Internet Explorer"
		End If
	ElseIf Instr(ua, "Mozilla") and Instr(ua, "compatible") = 0 Then
		If Instr(ua, "Netscape6") Then
			Browser = "Netscape Navigator 6.x"
		ElseIf Instr(ua, "Mozilla/4") Then
			Browser = "Netscape Navigator 4.x"
		ElseIf Instr(ua, "Mozilla/3") Then
			Browser = "Netscape Navigator 3.x"
		Else
			Browser = "Netscape Navigator"
		End If
	End If
	
	getBrowser = Browser
End Function

Mvh,

PeeerMedlem sedan mars 20025 907 inlägg
#3

Det borde ju tillomed jag ha förstått.. :r
Tackar & bockar!

125 ms totalt · 3 externa anrop · v20260731065814-full.30151723
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
122 ms — hämta tråd, inlägg och bilagor (db)