ASP Tutorial
ASP HOMEASP Introduction
ASP Install
ASP Syntax
ASP Variables
ASP Procedures
ASP Forms
ASP Cookies
ASP Session
ASP Application
ASP #include
ASP Global.asa
ASP Send e-mail
ASP Objects
ASP ResponseASP Request
ASP Application
ASP Session
ASP Server
ASP Error
ASP FileSystem
ASP TextStream
ASP Drive
ASP File
ASP Folder
ASP Dictionary
ASP ADO
ASP Components
ASP AdRotatorASP BrowserCap
ASP Content Linking
ASP Content Rotator
ASP and AJAX
AJAX IntroAJAX ASP
AJAX Database
ASP Summary
ASP Quick RefASP Summary
ASP Examples
ASP ExamplesASP Quiz
ASP Certificate
ASP Browser Capabilities Component
| « Previous | Next Chapter » |
ASP Browser Capabilities Component
The ASP Browser Capabilities component creates a BrowserType object that determines the type, capabilities and version number of a visitor's browser.
When a browser connects to a server, a User Agent header is also sent to the server. This header contains information about the browser.
The BrowserType object compares the information in the header with information in a file on the server called "Browscap.ini".
If there is a match between the browser type and version number in the header and the information in the "Browsercap.ini" file, the BrowserType object can be used to list the properties of the matching browser. If there is no match for the browser type and version number in the Browscap.ini file, it will set every property to "UNKNOWN".
Syntax
| <% Set MyBrow=Server.CreateObject("MSWC.BrowserType") %> |
ASP Browser Capabilities Example
The example below creates a BrowserType object in an ASP file, and displays some of the capabilities of your browser:
Example
Output:
Show example » |
The Browscap.ini File
The "Browsercap.ini" file is used to declare properties and to set default values for browsers.
This section is not a tutorial on how to maintain "Browsercap.ini" files, it only shows you the basics; so you get an idea what a "Browsercap.ini" file is all about.
The "Browsercap.ini" file can contain the following:
| [;comments] [HTTPUserAgentHeader] [parent=browserDefinition] [property1=value1] [propertyN=valueN] [Default Browser Capability Settings] [defaultProperty1=defaultValue1] [defaultPropertyN=defaultValueN] |
| Parameter | Description |
|---|---|
| comments | Optional. Any line that starts with a semicolon are ignored by the BrowserType object |
| HTTPUserAgentHeader | Optional. Specifies the HTTP User Agent header to associate with the browser-property value statements specified in propertyN. Wildcard characters are allowed |
| browserDefinition | Optional. Specifies 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 |
| propertyN | Optional. Specifies the browser properties. The following table lists some possible properties:
|
| valueN | Optional. Specifies the value of propertyN. Can be a string, an integer (prefix with #), or a Boolean value |
| defaultPropertyN | Optional. Specifies 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 | Optional. Specifies the value of defaultPropertyN. Can be a string, an integer (prefix with #), or a Boolean value |
A "Browsercap.ini" file might look something like this:
| ;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 beta=False ;DEFAULT BROWSER [*] browser=Default frames=FALSE tables=TRUE cookies=FALSE backgroundsounds=FALSE vbscript=FALSE javascript=FALSE |
| « Previous | Next Chapter » |
