User Agent Fun With Opera

When I was working with User Agent strings today, I made the unfortunate discovery that Opera claims to be MSIE (according to their knowledge base site, this is the default — or used to be, until version 8 according to this website and a friendly commenter here).

That is, of course, unpleasant, if a developer wants to display content to specific users based on their user agent. Unlike the current, ugly GeoIP epidemic (which I shall blog about another time), there are fairly good reasons for doing this — all of which are negatively impacted by claiming to be a specific browser if you are not. Let me just name three of these reasons, off the top of my head:

  1. Relevance. Some content (pictures, instructions, warnings) may simply not apply to people outside a specific user group.
  2. Workarounds. Particularly MSIE 6 was/is infamous for numerous bugs and inconsistencies, some of which can be worked around. There is little reason why anyone else would like to see these “hacks” applied to the page they are visiting.
  3. Differences in technology. Some people produce browser extensions for, for example, both Firefox and MSIE. They may want to serve appropriate instructions to these users, and maybe a third page to everyone else.

I am not only convinced some Opera users would be outraged to be served Internet-Explorer-only content. I also assume that through Opera’s claiming to be MSIE, Opera users can report numerous cases when the false user agent triggered some quirks on websites that were installed by the website author only to handle MSIE’s abundant bugs at the time. Why anyone would want this setting to be the default, I cannot understand: Claiming to “be somebody else” should be the exception, not the rule.

People have blogged before about the near-uselessness of the User Agent string (in connection with Google Chrome’s football-field-long UA string), and they have probably done a much better job than I would. From a developer perspective though, this is frustrating. So I twittered:

Uhm, why does Opera claim to be MSIE in its User Agent string?

followed by:

To be fair, only old versions of Opera do that.

and soon thereafter, I got this interesting answer from a friend:

… they were hoping to be accidentally bundled with Windows.

I must say, in the light of Opera being the initiator of the ongoing antitrust investigation of the European Commission against Microsoft, this answer does not fail to convey a faint notion of irony.

Update: Commenter Eric points out that Opera’s knowledge base article that I am citing on the top is outdated and the default user agent string used by Opera is much simpler. Well, excellent.

Update 2: Another commenter points out that Opera’s impersonating MSIE has historic reasons dating back to the pre-Firefox era. — Now that these reasons are not present anymore, the UA has been adapted.



7 Responses to “User Agent Fun With Opera”

  1. Perhaps you shouldn’t trust everything they say in the web. That article you linked is old (after all, it lists only Opera 6 and 7 as the current yet unreleased version is 10).
    Operas default user agent string in linux is: Opera/10.00 (X11; Linux x86_64; U; Edition Turbo; en) Presto/2.2.0

    So there is no even mention of Mozilla. Much more simpler and cleaner than example the Firefox string…

    Faint notion of irony is that somebody blogs about working with user agents and then doesn’t even apparently know what are the default user agents for different browsers…

  2. Thanks for your comment. That it is not the default *anymore* was what I guessed, though their — apparently outdated — knowledge base article convinced me otherwise.

    Thus, I added some clarifications to the article, now that I am sure my initial guess was correct.

  3. The reason that Opera used to pretend to be IE is because back in the olden days many used to sniff user-agent strings and either not display for any non-IE browser or provide a crippled version “optimised” for non-IE browsers (i.e. Netscape 4). It’s easy to forget that Opera faked its user-string long, long before Firefox even existed, and has origins in when every other browser was languishing so far behind IE to be meaningless, and Opera was the main alternative and was a commercial browser in a distant 2nd.

    Even today I’d argue relying on user-agent sniffing for /anything/ is generally a bad idea.

  4. Aha, thanks for the “history lesson”. And while I disagree that user-agent sniffing is *never* a good idea, I concur that its legitimate use cases are very, very small and, as a rule of thumb, most UA sniffing that’s currently present on the web is done for none of the “good reasons” I am mentioning in the article.

  5. There’s lots of fun out there regarding UA strings, and the first browser to impersonate a different one was actually MSIE itself by telling it would be “Mozilla/x.xx (compatible; …)” as “Mozilla/x.xx” was (supposed to be) the identifier for Netscape.
    The bad thing is that sometime sppofing or impersonating a different browser is needed for your browser not to be shut out (!) of some websites, which Camino and SeaMonkey for example felt or feel quite strongly. See my posts about the topic on http://home.kairo.at/?d=w&i=1&m=v&f.tags=UA+String for some more on those dirty things.

  6. Props to the commentors for picking up on the fact that the info in this article is dated. It had me going for awhile as my website stats clearly pick up opera users. I have Opera 9 and don’t think the browser still allows the user to spoof another type of browser (or at least I could not figure out how to use that capability). To the author, could of happened to anybody as you relied on the company’s own web site. One would think they would update that info given in the knowledge base or at least note that it only applies to older versions.

  7. ua sniffing is dumb test with js for features supported only by the browser you are targeting. if they have js disabled and your css is so lame you can’t target specific browsers with it, then you have no place pretending your a real web dev

    ua sniffing is LAME ALWAYS it’s NEVER a good idea (unless you serve special content to google… *cough*) :)