Detecting Browser Capabilities With BrowserHawk - Using BrowserHawk
(Page 4 of 6 )
The BrowserHawk ActiveX component can be instantiated in our ASP pages to retrieve the settings of any visitors' web browser (BrowserHawk has great online documentation and examples at
this site). The ProgID of the BrowserHawk component is "cyScape.browserObj". As with any other ASP component, it can be instantiated using ASP's Server.CreateObject method:
<%
dim objBH
set objBH = Server.CreateObject("cyScape.browserObj")Now that we've got a new instance of the BrowserHawk component, we can query it to retrieve the details of any visitors' browser. If you're using Visual Interdev to create your ASP pages, then you'll have the benefits of Microsoft's Intellisense feature when referring to an instance of the BrowserHawk object:

As you can see from the screen shot above, the BrowserHawk component exposes dozens and dozens of public methods and members that we can use to our advantage. For example, if I wanted to write the version of the visiting browser as part of my ASP pages output, then I would use the this line:
Response.Write "Your browsers version is " & objBH.Version... which would output "5.5". If I wanted to make sure that all visitors’ browsers have support for DHTML, then I could use the "DHTML" member of the BrowserHawk object, like this:
hasDHTML = objBH.DHTML
if hasDHTML = true then
Response.Redirect "coolsite.asp"
else
Response.Redirect "plainsite.asp"
end ifOne extremely useful feature of BrowserHawk is the ability to retrieve the details of a users connection speed. The SetExtProperties method tells the BrowserHawk component that we're after an extended property, meaning that the page must be reloaded to extract that specific property. The GetExtPropertiesEx method refreshes the page and retries the details for each property set using the SetExtProperties method. Here's the code to get the connection speed from a visitors browser:
objBH.SetExtProperties "ConnectionSpeed"
objBH.GetExtPropertiesEx
Response.Write "You are connected at " & objBH.Translate("ConnectionSpeed")The output from the ASP code above in my browser looks like this (I am connecting to my web server locally, which is why the connection speed is so high):

Here's a list of the popular browser features that BrowserHawk exposes through its interface:
- ActiveXEnabled
- Browser
- ColorDepth
- ConnectionType
- Cookies
- DHTML
- Frames
- JavaApplets
- JavaScript
- MSXML
- OSDetails
- ResolveIP
- SSL
- VBScript
Next: BrowserHawk example >>
More ASP Articles
More By Annette Tennison