In Part 1 we looked at how to use client-side scripting techniques and the User-Agent server variable to determine the user's browser type and version. In this part we will look at using two more server-side techniques: using Microsoft's Browser Capabilities component, and using a BrowserHawk, a commercial, third-party component.
Using Microsoft's Browser Capabilities
Microsoft provides a free component (and file) with IIS 4 and IIS 5 called Browser Capabilities. This component maps the visitor's User-Agent string to an entry in a file
BrowsCap.ini (it's located in the
\WinNT\system32\inetsrv directory on my computer). Under each listing of browser type in the file
are a number of properties, indiciating whether or not a specific browser and version supports a specific property.
This file, then, can be accessed programmatically through the Browser Capabilities component. For example, to
list the browser name and version, along with whether that browser can support frames, you could use code like:
The output of the above script, for your browser, can be seen below:
Your browser: Default
Browser version: 0.0
Support Frames? False
For another Browser Capabilities example, be sure to view our live demo.
Since the Browser Capabilities component determines a browser's properties through this file, it is important that
this file be updated when new browsers hit the market (such as Opera, or new version of IE or Netscape). You can
learn where to download the latest version of
this Microsoft article.
Also, for a more intricate Browser Capabilities code example, be sure to check out:
Browser Capabilities Code Sample.
Using BrowserHawk to Perform Browser Detection
The only downside to BrowserHawk is that it is not a free component. You can download a free version to play around with it and see if it meets your needs, but, to keep it from expiring, you'll eventually need to buy a copy, which can run from $119 to $489, depending on the version you're interested in.
For some great demos with BrowserHawk, be sure to read the following articles:
- Browser Detection using BrowserHawk
- How do I use BrowserHawk to Accomplish Certain Tasks?
- BrowserHawk FAQs
Well, that about wraps this article up! We've examined four different ways to perform browser detection. When it comes to browser detection and capabilities there's a trade-off between fast and free with few features and slower and more costly with many more features. Your choice should depend on what needs you have and what types of browser capabilities you need to be able to detect.