20.1. How to Detect User Agents?
Before we move on to discuss how to detect user agents, let's first have a look at the steps involved in a typical request-response cycle between a server and a client browser:
The WAP browser requests an XHTML MP page from the server.
The server receives the request and delivers the XHTML MP document to the WAP browser.
The WAP browser receives the XHTML MP document and finds that it contains a <link> tag that references to an external cascading style sheet.
The WAP browser sends another request to the server in order to obtain the WAP CSS cascading style sheet.
The server receives the request and delivers the WAP CSS cascading style sheet to the WAP browser.
The WAP browser receives the WAP CSS file and displays the XHTML MP page according to the style information contained in the WAP CSS file.
The steps repeat when the user selects an anchor link or types a new URL in the WAP browser.
As you can see from above, the only thing that the server receives from the client is the HTTP request. So, to determine the client's user agent, the server needs to rely on the information included in the HTTP request. Below shows a HTTP request example. It is a HTTP request generated by the Nokia 6230 emulator (some headers that are irrelevant to user agent detection are omitted).
User-Agent: Nokia6230/2.0 (03.14) Profile/MIDP-2.0 Configuration/CLDC-1.1
Both the profile header and the user-agent header can be used for user agent detection.
The profile header holds the URL to the UAProf (User Agent Profile) document of the wireless device. The UAProf document contains information about the wireless device's characteristics and capabilities such as screen size, character sets supported, number of softkeys supported, etc. The details of the profile header and the UAProf document is out of the scope of this section and it will be covered in a future article.
The user-agent header includes information like the wireless device's name, platform, Java capabilities, etc. The format of the user-agent header value is different for different brands of browsers. For example, the user-agent header format generated by Nokia mobile phone browsers are different from that generated by Sony Ericsson mobile phone browsers. Here is a user-agent header generated by Sony Ericsson Z1010:
User-Agent: SonyEricssonZ1010/R1A SEMC-Browser/4.0
Note that the user-agent header format may also vary among browsers of the same brand, although the variations are usually small.
Below is the user-agent header found in a HTTP request generated by Microsoft Internet Explorer 6 on Windows 2000:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
As a general rule, you should find the brand name of a mobile phone in its user-agent header value. For example, you should find the brand name "Nokia" in the user-agent header generated by a Nokia mobile phone, and you should find the brand name "SonyEricsson" in the user-agent header generated by a Sony Ericsson mobile phone.
If you find the word "Mozilla" in the user-agent header value, then the client browser should be a desktop web browser like Mozilla and Microsoft Internet Explorer. (Note that we have simplified things a bit here. Actually, the existence of the word "Mozilla" in the user-agent header value only indicates that it is very likely that the user agent is a desktop web browser, but does not mean it must be a desktop web browser. For example, some Nokia Series 60 mobile phones include the word "Mozilla" in their user-agent header to indicate that they are web-capable. However, note that the brand name "Nokia" is still present in their user-agent header value.)
|Previous Page||Page 37 of 39||Next Page|
- 1. WCSS (WAP CSS) Introduction
- 2. Wireless CSS and Wireless Profile CSS
- 3. Advantages of Using WAP CSS Style Sheets on Mobile Internet Sites
- 4. Disadvantages of Using WAP CSS Style Sheets on Mobile Internet Sites
- 5. Syntax Rules of WCSS
- 6. Comments in WCSS
- 7. How to Apply WCSS Styles to an XHTML MP Document
- 8. Different Types of Selectors
- 9. Div and Span Element of XHTML MP
- 10. Cascading Rules for Handling Multiple Groups of WCSS Styles Applied to the Same Element
- 11. Common Types of Property Value
- 12. WCSS Font and Text Properties
- 13. WCSS List Properties
- 14. WCSS Color Properties
- 15. WCSS Border Properties
- 16. WAP Specific Extensions to CSS
- 17. WCSS Access Key Extension
- 18. WCSS Input Extension
- 19. WCSS Marquee Extension
- 20. Matching WCSS Cascading Style Sheets to Different User Agents