...

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



bluephoenix
01-11-2003, 04:50 AM
Hrm. Okay...

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

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?

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

Skyzyx
01-11-2003, 11:04 AM
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.

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

scroots
01-11-2003, 07: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.

scroots

Skyzyx
01-11-2003, 08: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!

brothercake
01-14-2003, 12: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.

bluephoenix
01-14-2003, 03: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");
}

</script>

brothercake
01-14-2003, 01: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]);
if(KDEn>2.2){
kde=1;
ns6=1;
exclude=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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum