Call (877) SITE-OPT (748-3678)

Code: Sniffing with BrowserHawk

Chapter 6 - Web Page Optimization

Here is some sample code that shows how BrowserHawk is enabled in a page and some sniffed parameters:

<%
// First import the com.cyscape.browserhawk namespace
%>
<%@ page import = "com.cyscape.browserhawk.*" %>
<%
// Now we get an immutable (unchangeable) instance of the browser object which
// represents the "basic" properties this browser supports.
%>

<% BrowserInfo browser = BrowserHawk.getBrowserInfo(request); %>
<%
// At this point, our browser object contains all the basic browser capability
// information for the current visitor. Next, display this information to the screen
%>
Your browser is: <%= browser.getBrowser( ) %> <%= browser.getFullversion( ) %><P>
Your platform is: <%= browser.getPlatform( ) %><P>
Browser major version: <%= browser.getMajorver( ) %><P>
Browser minor version: <%= browser.getMinorver( ) %><P>
Container* browser: <%= browser.getContainerBrowser( ) %><P>
Container version: <%= browser.getContainerVersion( ) %><P>
Container full version: <%= browser.getContainerFullversion( ) %><P>
Supports AJAX? <%= browser.getXMLHttpRequest( ) %><P>
Supports ActiveX controls? <%= browser.getActiveXControls( ) %><P>
Browser data file version: <%= browser.getBDDVersion( ) %>, dated: <%= browser.
getBDDDate( ) %><P>
BrowserHawk version in use: <%= BrowserHawk.getVersion( ) %><P>

For extended properties that can change with each session, you use the following code:

<%
// First we create the ExtendedOptions object. This object is used to
// set various preferences and options, such as selecting which
// extended properties we want tested and related testing parameters.
ExtendedOptions options = new ExtendedOptions( );
// Now we tell BrowserHawk which tests we want it to perform on the
// browser. If there are other settings you want to check as well, you can
// just add them to this list. See the ExtendedOptions class in the
// BrowserHawk documentation for more information.
%>
options.addProperties("PersistentCookies, SessionCookies, JavaScriptEnabled, Width,
Height, WidthAvail, HeightAvail, Plugin_Flash, Broadband");
Session cookies enabled? <%= extBrowser.getSessionCookies( ) %><p>
Persistent cookies enabled? <%= extBrowser.getPersistentCookies( ) %><p>
JavaScript enabled? <%= extBrowser.getJavaScriptEnabled( ) %><p>
Screen resolution: <%= extBrowser.getWidth( ) %> x <%= extBrowser.getHeight( ) %><p>
Available browser window size: <%= extBrowser.getWidthAvail( ) %> x <%= extBrowser.
getHeightAvail( ) %><p>
Flash plug-in version installed: <%= extBrowser.getPluginFlash( ) %><p>
Broadband connection? <%= extBrowser.getBroadband( ) %><p>
Copyright © 2002-2017 Website Optimization, LLC. All Rights Reserved - Free website speed test - Privacy Policy
Last modified: February 19, 2009.

Follow us on: Twitter, Google+, Facebook, Linked In