Home arrow ASP arrow Page 4 - Detecting Browser Capabilities With BrowserHawk
ASP

Detecting Browser Capabilities With BrowserHawk


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.

Author Info:
By: Annette Tennison
Rating: 5 stars5 stars5 stars5 stars5 stars / 17
February 19, 2002
TABLE OF CONTENTS:
  1. · Detecting Browser Capabilities With BrowserHawk
  2. · What is BrowserHawk
  3. · The BrowserHawk application
  4. · Using BrowserHawk
  5. · BrowserHawk example
  6. · Conclusion

print this article
SEARCH DEVARTICLES

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:

Intellisense helps us remember BrowserHawks methods

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 if


One 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):

Using the ConnectionSpeed BrowserHawk value

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

blog comments powered by Disqus
ASP ARTICLES

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials