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 - 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")
I'm using Internet Explorer 5.5 with all of the features we require enabled, so the output from my browser looks like this:
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: