View Full Version : Opera Browser Detect... What Gives?

01-11-2003, 05:50 AM
Hrm. Okay...

<script language="javascript" type="text/javascript">
var browser=navigator.appName;
document.write("You\'re using: ", browser);

results "You're using: Microsoft Internet Explorer" with MSIE.
results "You're using: Netscape" with NN.
but, results "You're using: Microsoft Internet Explorer" with Opera.

What's up with that?

01-11-2003, 06:32 AM
This thread covers Opera detect (http://www.codingforums.com/showthread.php?threadid=3811&highlight=browser)

01-11-2003, 12:04 PM
It all depends on what you have Opera set to identify as. Set it to identify as Mozilla/5.0 or as Opera, it that info will change.

If you read my other post, it'll detect Opera regardless of what it identifies as.

01-11-2003, 02:43 PM
this script (http://www.brothercake.com/scripts/sniffer.php) includes detectin for O5,O6 and O7

01-11-2003, 08:56 PM
when you have built your script post a link and people who use opera (like me) will see if your script can detect opera.


01-11-2003, 09:26 PM
nice sniffer, brothercake!

I don't suppose you have a userAgent value for Konqueror and k-meleon, do you? I've almost got everything nailed down for my sniffer I've been working on for a while.

It'd be a huge help!

01-14-2003, 01:00 AM
This is knoqueoror 3 on red hat 8.0

Mozilla/5.0 (compatible; Konqueror/3; Linux)

you can always rely on the "Konqueror/X.X" arrangement, and you also have "navigator.vendor" which only Konqueror has (but of course is all versions, not just 3+). I find 2.2+ a useable group, but only 3.0+ really counts as a "good browser"

I don't have k-meleon here; i'll check it at work tomorrow.

01-14-2003, 04:25 AM
so for knoqueoror the detection routine would be if (navigator.vendor!="undefined")?

here's what I've got in regards to the opera:

<script language="javascript">
if (typeof window.opera!="undefined") {
document.write("You're using Opera");
} else
if (navigator.appName=="Netscape") {
document.write("You're using Netscape.");
} else
if (navigator.appName=="Microsoft Internet Explorer") {
document.write("You're using MS Internet Explorer");


01-14-2003, 02:26 PM
Originally posted by bluephoenix
here's what I've got in regards to the opera:

The thing with Opera is that 5,6 and 7 are all completely different in terms of behaviour and support; treating them the same is no more useful than treating ie4 and ie6 the same.

Originally posted by bluephoenix
... Konqueror detection ..

What I do is this:

if(typeof navigator.vendor!="undefined"){
if (navigator.vendor=="KDE"){
var thisKDE=agt;
var splitKDE=thisKDE.split("konqueror/");
var aKDE=splitKDE[1].split("; ");
var KDEn=parseFloat(aKDE[0]);

The navigator.vendor tells me it's konqueror, which I use as a broad-knife, in order that I know the UA string format I'm dealing with. Then I split that up so that version >=2.2 return true for (kde) while lower versions return false. For ease, I let it return true for (ns6) as well; just a personal shortcut which is arguably counter productive in some situations.

btw - Skyzyx - here's a k-meleon UA string. It's from 0.6 which isn't the latest version, I don't think, but it also returns its gecko version.

Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.5) Gecko/20011011

I've never found the need to identify gecko browser individually, apart from a switch that differentiates between Netscape builds and others.