One of the constant non-niceties when developing web sites is that of browser incompatibility. In this article Annette looks at Cyscape's BrowserHawk component, which can be used to find out the capabilities of any visitors web browser. Annette talks about the component in general, and also shows us a complete working example that detects flash, MSXML, connection speeds, and more.
Detecting Browser Capabilities With BrowserHawk - The BrowserHawk application (Page 3 of 6 )
BrowserHawk is installed as a Windows NT service. It comes bundled with the BrowserHawk application, which allows us to view the definitions and properties of each web browser. Each browser definition contains the details of several properties that are unique to that browser, such as its version string and version number. The BrowserHawk application looks like this:
So where exactly does BrowserHawk get the details of each visitors browser from? Well, whenever we use our web browser to visit a web site, our browser sends that site a set of details as part of its request header. We can view all of our browser's header variables by iterating through ASP's Request.ServerVariables collection, like this:
Here's the output from the code above in my browser (I run Internet Explorer 5.5 on a Windows 2000 server):
I've circled the HTTP_USER_AGENT variable in my screen capture above. BrowserHawk uses this value as the basis for selecting which browser any visitor that comes to our site is using. The "MSIE 5.5" string tells BrowserHawk that I am running Internet Explorer 5.5, and the "Windows NT 5.0" tells BrowserHawk that I'm running Windows 2000.
If you take the code snippet shown above and run it through your browser, you'll notice several other variables in the list that relate to the details of your web browser, namely HTTPS, PATH_INFO, REMOTE_ADDR, and HTTP_COOKIE.
Luckily, when we use the BrowserHawk component in our ASP pages, we don't have to analyze the visitors’ browser manually. All we have to do is query a new instance of the BrowserHawk component for the values we're after. We will proceed to do that now.