TBrowserType Component

Written by Yaniv Golan, ygolan@hyperact.com

TBrowserType is part of the HyperAct WebApp Framework.

The TBrowserType component reports the capabilities of a browser based on the HTTP User Agent header.

The capabilities are determined using the file BROWSCAP.INI. This file is in a format compatible with the format used by the Microsoft Active Server Pages component MSWC.BrowserType, and is documented in the Microsoft ASP documentation (http://www.microsoft.com/msdn/sdk/platforms/doc/denali/aspdocs/ref/comp/compref_11.htm).

TBrowserType is usefull for CGI applications that wish to customize their output according to the capabilities of the requesting browser.

Properties

BrowserCap The name of the INI file that contains the user agents capabilities. The value of this property defaults to BROWSCAP.INI. The component will search for the file using the standard INI file search path. To specify another file, use a fully qualified name.
UserAgent The value of the HTTP USER-AGENT header
Browser The browser's generic name (e.g. IE, Netscape, etc.)
MajorVer The browser's major version number
MinorVer The browser's minor version number
Platform The platform that the browser is running on (e.g. Win16, Win95 etc.)
Frames Does the browser support frames ?
Tables Does the browser support tables ?
Cookies Does the browser support HTTP cookies ?
BackgroundSounds Does the browser support background sounds ?
VBScript Does the browser support Visual Basic Script ?
JavaScript Does the browser support JavaScript ?
JavaApplets Can the browser run Java Applets ?
ActiveXControls Can the browser run ActiveXControls ?
Beta Is the browser a beta version ?
Count The number of properties available for the specified user agent
Keys A integer-indexed array of property names in the range 0 to (Count - 1)
Values The properties collection, can be accessed either by a index (integer) or by property name (string). This is the default array property.

Methods

None.

Events

None.

Remarks

Before using the component, set the UserAgent property to the value extracted from the HTTP USER-AGENT header :

BrowserType.UserAgent := Request.ServerVariables['HTTP_USER_AGENT'];

If the capability you wish to query appears in the generic properties list, you can access it directly :

 if (BrowserType.Tables) then
   Response.Write("<TABLE>");

If you wish to query a custom property that does not appear in the generic properties list, use the Values property with the custom property name as an index. Note that since the Values property is the default array property, you can use the following syntax :

if (BrowserType['AOL'] = true) then
  ....

To enumerate all the known properties :

for i := 0 to (BrowserType.Count - 1) do
  Response.Write(BrowserType.Keys[i] + ' = ' + BrowserType[i]);

To obtain an updated BROWSCAP.INI, check http://www.microsoft.com/iis.

Microsoft Active Server Pages is a registered trademark of Microsoft.