Home arrow ASP arrow Page 5 - 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 - BrowserHawk example
(Page 5 of 6 )

Now that we've taken a look at the BrowserHawk application and some of its methods and members, let's create an example that uses BrowserHawk to its fullest extent.

Let's pretend for a minute that we're creating an extremely bandwidth-intensive site that requires its users to have a minimum connection speed of 20KB/second, Flash support, a minimum screen resolution of 1024x768, JavaScript enabled, and at least version 3 of Microsoft’s MSXML parser.

Here's the ASP code that we could use to check that the visitors web browser conforms to the requirements outlined above:

<%

On Error Resume Next

dim objBH

dim strSpeed

dim lngSpeed

dim intCDepth

dim blnFlash

dim intWidth

dim intHeight

dim blnJS

dim blnMSXML

dim strErr



set objBH = Server.CreateObject("cyScape.browserObj")



// Get the browsers extended properties

objBH.SetExtProperties "ConnectionSpeed, Height, Width, JavaScriptEnabled, MSXML"

objBH.GetExtPropertiesEx



// Save the results as variables

strSpeed = objBH.Translate("ConnectionSpeed")

blnFlash = CBool(objBH.Plugin_Flash)

intWidth = CInt(objBH.Width)

intHeight = CInt(objBH.Height)

blnJS = CBool(objBH.JavaScriptEnabled)

blnMSXML = CBool(objBH.MSXML)



// Extract the numerical speed as KB's

lngSpeed = CLng(Mid(strSpeed, Instr(1, strSpeed, "(") + 1, Instr(1, strSpeed, " ")-1))



if lngSpeed > 20 and blnFlash and intWidth >= 1024 _

and intHeight >= 768 and blnJS and blnMSXML then

'Users browser conforms to our requirements

Response.Write "Your browser passed our test"



else



strErr = "<ul>"



if lngSpeed < 20 then

strErr = strErr & "<li>Your connection speed is too sow</li>"

end if



if not blnFlash then

strErr = strErr & "<li>You need flash</li>"

end if



if intWidth < 1024 or intHeight < 768 then

strErr = strErr & "<li>You need at least a 1024 x 768 resolution</li>"

end if



if not blnJS then

strErr = strErr & "<li>You need JavaScript enabled</li>"

end if



if not blnMSXML then

strErr = strErr & "<li>You need MSXML enabled</li>"

end if



strErr = strErr & "</ul>"



Response.Write "Your browser failed our test:<br>"

Response.Write strErr



end if



%>


I'm using Internet Explorer 5.5 with all of the features we require enabled, so the output from my browser looks like this:

IE with all required features enabled

By turning of JavaScript from the tools menu, several of BrowserHawk's features are disabled. Here's the output in my browser when JavaScript is disabled:

IE with some required features enabled
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