Information Technology Reference
In-Depth Information
RFC 1945, many vendors add additional information such as the operating system,
loaded extensions, and platform details. The built-in browser on a Google Nexus One,
running Android 2.2 (Froyo) sends the following user agent:
Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1
(KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
This string, broken down, translates to:
Mozilla 5.0 browser
Running on a Linux operating system, specifically Android 2.2
Using the language English—US (en-us)
On a Nexus One phone, running build FRF91 of the operating system.
Which (the comment instructs) is like an AppleWebKit browser (version 533.1).
A lot of information is available to our web page or application (and if you look at the
RFC, more information might even be available in terms of the engine or the level of
security the current browser offers). Using this, we can direct users of specific phones,
browsers, operating system, and languages to specially formatted pages we've created
for them or display features specific to that browser which we are targeting.
However, there is one caveat to consider with user agent detection: User Agent
Spoofing. Many third-party browsers, such as the popular Dolphin HD browser on
Android, allow users to set their own user agent. There are multiple reasons for this,
including:
The user wants to see the desktop version of a page, no matter how
horribly formatted it might look.
The user wants to access pages that are specifically built for another
operating system or browser (i.e., perhaps the web developer hasn't
built an optimized Android version yet, but has an optimized iOS
version.)
The user just wants to appear to the website's logs as a desktop
system, for some reason or another! One that comes to mind is a
restriction placed by the developer (i.e., only show a special offer to a
desktop user) that the mobile user wishes to view.
There isn't much one can do about user agent spoofing. After all, the setup of the entire
system revolves around the user agent being reported accurately. If this is a concern of
yours, you may want to use alternatives in addition to user agent detection to deliver the
correct page to your user, despite what they want. This typically would take the form of
scripts that could test for capabilities of a browser—however, one would need to know
which minute capabilities mobile browsers have and which only desktops would have—
which is well beyond our scope here.
Now that you have a basic understanding of what the user agent string is used for, let's
take a look at a few examples where we detect a user agent string of our end user.
 
Search WWH ::




Custom Search