Browscap.ini File

You can declare property definitions for any number of browsers in the Browscap.ini file. You can also set default values to use if the client's browser is not one of the listed definitions.

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 28
January 01, 2002
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

 

You can declare property definitions for any number of browsers in the Browscap.ini file. You can also set default values to use if the client's browser is not one of the listed definitions.

For each browser definition, you provide an HTTP User Agent header and the properties and values you wish to associate with that header. For more information on the format of the HTTP User Agent header, refer to the HTTP specification available at http://www.w3.org.

Syntax

[; comments]

[HTTPUserAgentHeader]

[parent = browserDefinition]

[property1 = value1]

...

[propertyN = valueN]

 

[Default Browser Capability Settings]

[defaultProperty1 = defaultValue1]

...

[defaultPropertyN = defaultValueN]


Parameters
comments
Any line that starts with a semicolon (;). Comments, which are ignored by the BrowserType object, can occur anywhere in the Browscap.ini file.
HTTPUserAgentHeader
Specifies the HTTP User Agent header to associate with the browser-property value statements specified in propertyN. The Browscap.ini file may contain multiple browser definitions, each one starting with a unique HTTPUserAgentHeader value.

You can use the asterisk (*) character as a wildcard character in HTTPUserAgentHeader to replace zero or more characters and the (?) character as a wildcard to replace a single character.

For example, if you specified the following string for HTTPUserAgentHeader:

[Mozilla/4.0 (compatible; MSIE 5.0;* Windows NT)]

 

It would match all of the following User Agent headers:

[Mozilla/4.0 (compatible; MSIE 5.0; Windows NT)]

[Mozilla/4.0 (compatible; MSIE 5.0; AK; Windows NT)]

[Mozilla/4.0 (compatible; MSIE 5.0; SK; Windows NT)]

Note   The BrowserType object first attempts to match the HTTP User Agent header to a value of HTTPUserAgentHeader exactly. If that fails, it attempts to make a match that uses wildcard characters.

If more than one browser definition containing wildcard characters matches the User Agent header, the BrowserType object returns the properties of the definition which most closely matches the User Agent header. The closest match is the match which replaces the fewest characters.

browserDefinition
An optional parameter specifying the HTTP User Agent header-string of a browser to use as the parent browser. The current browser's definition will inherit all of the property values declared in the parent browser's definition. This helps define properties for a new version of a browser, because new versions usually retain most of the properties of the previous release. These inherited property values can be overwritten by explicitly setting a new value for the property by using the syntax propertyN = valueN.
propertyN
An optional parameter specifying the name of the browser property to set. It must start with an alphabetic character and cannot be longer than 255 characters. Each browser definition in the Browscap.ini file can contain as many statements of property values as needed. For example, if your application only needed to know whether or not a user's browser supported VBScript, you would only need one property statement for each browser definition.

The following table lists some possible properties:

PropertyDescription
ActiveXControlsSpecifies whether the browser supports ActiveX® controls.
BackgroundsoundsSpecifies whether the browser supports background sounds.
BetaSpecifies whether the browser is beta software.
BrowserSpecifies the name of the browser.
CdfSpecifies whether the browser supports the Channel Definition Format for Webcasting.
CookiesSpecifies whether the browser supports cookies.
FramesSpecifies whether the browser supports frames.
JavaappletsSpecifies whether the browser supports Java applets.
JavascriptSpecifies whether the browser supports JScript.
PlatformSpecifies the platform that the browser runs on.
TablesSpecifies whether the browser supports tables.
VbscriptSpecifies whether the browser supports VBScript.
VersionSpecifies the version number of the browser.


valueN
An optional parameter specifying the value of propertyN. This value is a string by default. To specify an integer, prefix the value with a number sign (#). To specify a Boolean value, use TRUE or FALSE.
defaultPropertyN
An optional parameter specifying the name of the browser property to which to assign a default value if none of the defined HTTPUserAgentHeader values match the HTTP User Agent header sent by the browser.
defaultValueN
An optional parameter specifying the value of defaultPropertyN. This value is a string by default. To specify an integer, prefix the value with a number sign (#). To specify a Boolean value, use TRUE or FALSE.
Example

In the following example, the parent tag allows the second browser definition to inherit from the first, so that the Microsoft® Internet Explorer 5.x definition inherits all the properties of Microsoft® Internet Explorer 5.0 definition (for example, frames=TRUE, tables=TRUE, and cookies=TRUE). It adds platform-specific information by adding the line, platform=WinNT.

;;ie 5.0
[IE 5.0]
browser=IE
Version=5.0
majorver=#5
minorver=#0
frames=TRUE
tables=TRUE
cookies=TRUE
backgroundsounds=TRUE
vbscript=TRUE
javascript=TRUE
javaapplets=True
ActiveXControls=TRUE
Win16=False
beta=False
AK=False
SK=False
AOL=False
;;ie 5.x
[Mozilla/4.0 (compatible; MSIE 5.*; Windows NT)]
parent=IE 5.0
version=5.0
minorver=0
platform=WinNT
; Default Browser 
[*]
browser=Default
frames=FALSE 
tables=TRUE 
cookies=FALSE 
backgroundsounds=FALSE 
vbscript=FALSE 
javascript=FALSE
blog comments powered by Disqus
ASP ARTICLES

- Using MySQL with ASP
- ADO for the Beginner
- ADO.NET 101: Data Rendering with a DataGrid ...
- Introducing SoftArtisans OfficeWriter 3.0 En...
- Getting Remote Files With ASP
- The Real Basics of Functions in ASP
- Enhancing Readability with ASP
- Mimicking PHP's String Formatting Functions
- Windows Server Hacks 12, 77, and 98
- How to Sort a Multi-Dimensional Array
- Developing an Information Management Tool wi...
- What are Active Server Pages?
- Getting Remote Pages with ASP
- FTP’ing Files with ASP
- Apply Single-Sign-On to Your Application

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials