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:

BrowserHawk comes with browser definitions for 32 different browser types, including those for Netscape, Microsoft, Oracle, Lynx, MCSA Mosaic, WebTV, Konqueror, Mozilla and more. If you so desire, you can also create your own browser definition. This could come in handy if you only require a certain amount of features from a visitor's browser, and not a complete set of features. For example, you might create a new browser type called "MyBrowser". In order for a visitor to view your site, their browser must match all features of the MyBrowser type, which could include support for MSXML, DHTML, JavaScript and cookies.
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:
<%
for each item in Request.ServerVariables
Response.Write "<b>" & item & ":</b> "
Response.write Request.ServerVariables(item) & "<br>"
Next
%>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.
Next: Using BrowserHawk >>
More ASP Articles
More By Annette Tennison