Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

Browsecap.ini File: ASP Browser Capabilities Component

The Browscap.ini (called libchilicap.ini on UNIX) file contains information about each known browser. It is a standard text file that lists features a browser supports. The Browscap.ini file maps browser capabilities to the HTTP User Agent header.

It is important to keep your Browscap.ini or libchilicap.ini file up to date. When new browsers are released their capabilities are unknown to the current file, and pages that rely on browser detection may fail. You can obtain updates to Browscap.ini at:

http://www.cyscape.com/browscap/

To use the Browscap.ini file on UNIX, you must convert the text file to UNIX format and rename it "libchilicap.ini." You should rename your existing libchilicap.ini file "libchilicap.old" before installing the updated version.

You can also maintain the Browscap.ini file by editing the Browscap.ini file. A default section of the Browscap.ini file is used when the browser details don't match any of the ones specified. If the browser in use doesn't match any in the Browscap.ini file, and no default browser settings are specified, all properties are set "UNKNOWN."

Note

The Browscap.ini (or libchilicap.ini) file must be in the same directory as Browscap.dll or libchilicap.so.

To use the Browser Capabilities Component, it is necessary to create an instance of it and refer to its properties. To avoid having the Browscap.ini file accessed every time, read the value once and assign it to a variable:

Set objBCap = Server.CreateObject("MSWC.BrowserType")

Syntax: Browsecap.ini File HTTPUserAgentHeader Section

The HTTPUserAgentHeader section of Browscap.ini (libchilicap.ini on UNIX) defines the properties for a particular browser. The syntax is as follows:

[HTTPUserAgentHeader]

parent = browserDefinition

property1 = value 1

property2 = value 2

.

.

.

Parent

Another definition contains more information for that browser

value 1

A number used to map a capability for the first property listed.

value 2

A number used to map a capability for the second property listed.

Browsecap.ini File Default Section

The Default section of Browscap.ini (libchilicap.ini on UNIX) lists the properties and values to be used if the current browser isn't listed in its own section (or, if listed, not all properties are supplied). The following is the syntax for the default section of the Browscap.ini file:

[Default Browser Capability Settings]

defaultProperty1 = default value 1

defaultProperty2 = default value 2

.

.

.

default value 1

A number used to map a default capability for the first property listed.

default value 2

A number used to map a default capability for the second property listed.

Examples: Browsecap.ini File Default Section

This example shows entries for Internet Explorer (IE) 3.0. Since it has no parent line, the only properties its has (other than those defined in the default section) are those explicitly defined:

[IE 3.0]

browser=IE

Version =3.0

majorver=#3

minorver=#0

frames=TRUE

tables=TRUE

cookies=TRUE

vbscript=TRUE

javascript=TRUE

ActiveXControls=TRUE

In the following example IE 3.0 is specified as the parent for the browser. The properties explicitly provided replace, or add to, those values in the parent's definition:

[Mozilla/2.0 (compatible; MSIE 3.01; Windows 95)]

parent=IE 3.0

version = 3.01

minorver=01

platform=Win95

[Default Browser Capability Settings]

browser=Default

frames=FALSE

tables=FALSE

cookies=FALSE

backgroundsounds=FALSE

vbscript= FALSE

javascript= FALSE

. . .

To determine if a browser supports JavaScript use the following code:

bc = Server.CreateObject("MSWC.BrowserType")

if bc.javascript = 0 then

Response.Write "This browser does not support JavaScript."

else

REM The browser supports JavaScript so simply continue.

end if

The following example determines if a browser supports tables:

bc = Server.CreateObject("MSWC.BrowserType")

if bc.tables = 0 then

Response.Write "This browser does not support tables."

. . .

The following example uses the Browser Capabilities component to display a table showing some of the capabilities of the current browser:

<% Set bc = Server.CreateObject("MSWC.BrowserType") %>

<table border=1>

<tr><td>Browser</td><td> <%= bc.browser %>

<tr><td>Version</td><td> <%= bc.version %> </td></TR>

<tr><td>Frames</td><td>

<% if (bc.frames = TRUE) then %> TRUE

<% else %> FALSE

<% end if %> </td></TR>

<tr><td>Tables</td><td>

<% if (bc.tables = TRUE) then %> TRUE

<% else %> FALSE

<% end if %> </td></TR>

<tr><td>BackgroundSounds</td><td>

<% if (bc.BackgroundSounds = TRUE) then %> TRUE

<% else %> FALSE

<% end if %> </td></TR>

<tr><td>VBScript</td><td>

<% if (bc.vbscript = TRUE) then %> TRUE

<% else %> FALSE

<% end if %> </td></TR>

<tr><td>JScript</td><td>

<% if (bc.javascript = TRUE) then %> TRUE

<% else %> FALSE

<% end if %> </td></TR>

</table>

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.