---
title: "http_user_agent - Opera tror han är IE"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/132275-http-user-agent-opera-tror-han-är-ie"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "kolas"
published: "2005-08-03T22:33:03.000Z"
updated: "2005-08-04T07:44:01.000Z"
replies: 5
views: 339
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/132275-http-user-agent-opera-tror-han-är-ie"
---

# http_user_agent - Opera tror han är IE

## #1 — kolas, 2005-08-03T22:33Z

Med denna kod så tror Opera att han är IE, hur kommer man runt så att man kan skriva ut nå´t ENBART för IE?

```
If instr(lcase(Request.ServerVariables("HTTP_USER_AGENT")), lcase("msie")) > 0 Then 
response.write "endast Explorer"
else
response.write "alla andra läsare"
end if
```

Permalänk: https://www.webforum.nu/p/132275

## #2 — Peeer, 2005-08-04T06:52Z

Rätta mig om jag har fel nu, men har inte Opera en inbyggd funktion för att "identifiera" sig som just IE? Då kommer user_agent-strängen vara identisk för både IE och Opera...

Permalänk: https://www.webforum.nu/p/1653791

## #3 — Erik Juhlin, 2005-08-04T06:59Z

Det går inte att förlita sig på USER_AGENT för att identifiera webbläsare.

Permalänk: https://www.webforum.nu/p/1653793

## #4 — kolas, 2005-08-04T07:28Z

Jo det är väl nå´t sånt att den identifierar sig som IE, Opera skriver ut:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Opera 7.51 \[en\]

och IE:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; (R1 1.5); .NET CLR 1.1.4322) 

Men hur kan man göra smartast och relativt säkert för att skilja dem åt?

Permalänk: https://www.webforum.nu/p/1653794

## #5 — sonta, 2005-08-04T07:35Z

Så här kanske..

```
If instr(lcase(Request.ServerVariables("HTTP_USER_AGENT")), lcase("msie")) > 0 and instr(lcase(Request.ServerVariables("HTTP_USER_AGENT")), lcase("opera")) < 0  Then 
response.write "endast Explorer"
else
response.write "alla andra läsare"
end if
```

/Pelle

Permalänk: https://www.webforum.nu/p/1653797

## #6 — kolas, 2005-08-04T07:44Z

Löste det på ett annat sätt:

```
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 = "background-attachment: fixed;"
		ElseIf Instr(ua, "MSIE 5.") Then
			Browser = "background-attachment: fixed;"
		ElseIf Instr(ua, "MSIE 4.") Then
			Browser = "background-attachment: fixed;"
		ElseIf Instr(ua, "MSIE 3.") Then
			Browser = ""
			If Instr(ua, "MSIE 3.02") Then
				Browser = ""
			End If
		Else
			Browser = ""
		End If
	ElseIf Instr(ua, "Mozilla") and Instr(ua, "compatible") = 0 Then
		If Instr(ua, "Netscape6") Then
			Browser = ""
		ElseIf Instr(ua, "Mozilla/4") Then
			Browser = ""
		ElseIf Instr(ua, "Mozilla/3") Then
			Browser = ""
		Else
			Browser = ""
		End If
	End If
	
	getBrowser = Browser
End Function
```

Permalänk: https://www.webforum.nu/p/1653800

---

Tråden på webben: https://www.webforum.nu/amne/asp/132275-http-user-agent-opera-tror-han-är-ie
