ASP
  Home arrow ASP arrow Page 5 - Detecting Browser Capabilities With Browse...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

Detecting Browser Capabilities With BrowserHawk
By: Annette Tennison
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2002-02-19

    Table of Contents:
  • Detecting Browser Capabilities With BrowserHawk
  • What is BrowserHawk
  • The BrowserHawk application
  • Using BrowserHawk
  • BrowserHawk example
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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

    More ASP Articles
    More By Annette Tennison


     

    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...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway