Detect OS and browser

hmmm…that’s interesting :scratch:

Now that you mention it, I now do recall that there were issues with Opera spoofing other browsers back in its early days. I am not sure if that is still an issue nowadays.

I download all my browsers (IE, FF, Safari, Google and Opera) from the manufacturers’ website so hopefully I am getting a legitimate version of the browser.

When I output the navigator.useragent from my Opera v10 I get

Opera/9.80 (Windows NT 6.0; U; en) Presto/2.2.15 Version/10.00

My javascript looks for the string “Opera” in the useragent.

If it finds it, it then looks for the string “Version/”.

If it finds it, I then have Opera v10+ and it does a .split() using “Version/” to get the version number.

If it doesn’t, then I have Opera 9- and I do a split() on “Opera” to get the version number.

My javascript works fine on “legitimate” installations of the browsers I support.

Sure but the issue is, people change them (sometimes they are encouraged to when a site blocks their browser). People are much less likely to change the OS version though.

barrio: if you really want everyone to have access to this file, whatever it is, you’ll want something as a default if the user doesn’t have Flash. Since you’re using Javascript for OS detection anyway, detect if they
-have Flash
-have a Flash player that’s new enough (if version matters)

Adobe has been a pain regarding Flash for Linux. I remember when we were all sitting around waiting for Flash 9 because the older versions worked terribly for Linux… back then, it was built only for Firefox. To get Opera and Chrome to also use the Flash plugin, you had to tell those browsers to look in the .mozilla folder. Later, Opera started shipping with that as the default action. Chrome I think started copying the .mozilla folder and Flash is in .chrome… I think. I’m not sure anymore, because I’ve not allowed Flash to come onto my current distro. I only have Flash on the Windows machines.

Or, if that’s too much work, you can just have the default be a message which says “this is a Flash file. In order to view it, you must have Flash Player version whatever”.

I dont want it to be super specific about stuff, I just want it to detect OS and browser that’s it. I got it to detect the browser now I’m looking for the OS detection.

You might be able to use ppk’s script from QuirksMode:
http://www.quirksmode.org/js/detect.html

The top one does OS detection (as well as some browser detection). However if you look at the page I linked to earlier (http://my.opera.com/community/openweb/idopera/), you’ll see as you scroll down that if the user is on a mobile, the place where OS is usually listed (first in the ()'s) has other stuff like S60 for Symbian or J2ME/MIDP for phones running the Java virtual machine.

But if you’re only going for Desktop users right now, and are careful in updating your script for whatever other OSes you are looking for, try ppk’s script out.

I’m starting to get a little confused :confused: as there seem to be a couple of sub-threads happening here but I assume the “them” is user agents fields.

If that is so, then if someone changes the user agent in their browser I don’t see it as an issue for me because I support only legitimate versions of browsers.

So if a user changes the user agent in their browser and for some reason any of my web pages consequently do not render correctly then it’s not my problem because they are using an illegitimate user agent for the browser.

If the web page renders correctly with or without a legitimate user agent then all’s well and good because no harm has been done from my point of view.