The Browser Capabilities Component

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

THE BROWSER

CAPABILITIES
COMPONENT
DONE BY:

HARINI.D
1732J08
SYNOPSIS:
◦ INTRODUCTION
◦ BROWSER CAPABILITIES COMPONENT
◦ SYNTAX
◦ REASON BEHIND BROWSER CAPABILITIES COMPONENT
◦ THE BROWSCAP.INI FILE
◦ SYNTAX FOR BROWSCAP.INI FILE
◦ FUNCTIONALITY OF BROWSER CAPABILITIES COMPONENT (BROWSCAP.INI
FILE)
◦ SYNTAX FOR THE PROPERTIES IN BROWSCAP.INI FILE
◦ EXAMPLE
◦ OUTPUT
◦ CONCLUSION
INTRODUCTION:
◦ Browser capability means whether a particular browser support different features like java
script, Frames, Cookies, etc.

◦ Different types of features are being supported by different browsers or by the different
versions of the same browser.

◦ When we make a request for a page to the server through the browser then Asp.net
automatically determines the browser capabilities and render the appropriate markup for that
particular browser. However, sometimes some control features are not being supported by
older browsers.

◦ Sometimes we need to check the browser capabilities in our application.

◦ So, we can do this with the help of HttpBrowserCapabilities object.


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 "Browscap.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")
%>
REASON BEHIND BROWSER CAPABILITIES
COMPONENT:

◦ The recent plethora of new Web technologies has created a dilemma for Web authors.

◦ Which technologies do you use to design your Web pages? VBScript (Visual Basic, Scripting
Edition), ActiveX controls, Java applets, frames, and cascading style sheets are each
supported in some browsers but not in others.

◦ So do you write applications that only the most technically capable browsers can use?

◦ The Browser Capabilities component helps you solve this problem.

◦ You can check a browser's capabilities and send HTML that you know the browser can
handle.
THE BROWSCAP.INI FILE:
◦The "Browscap.ini" file is used to declare properties and to set default values for browsers.

◦The browscap.ini file's layout is like any other .ini file, and it must be in the same directory
as the component itself (the browscap.dll file).

◦The default location for these files in IIS is C:\WINNT\system32\inetsrv.

◦Within the browscap.ini file, each browser definition has its own section and each section
has any number of properties that you can set.

◦You can also insert comments in the browscap.ini file, which are indicated by a semicolon
(;).

◦You can use comments anywhere in the file.


SYNTAX FOR BROWSCAP.INI FILE:
◦ The HTTP user agent header within browscap.ini defines a browser's section. It must be enclosed in brackets, as shown here:

[IE 4.0]

◦ You can use an asterisk as a wildcard in the HTTP user agent header. If the Browser Capabilities component cannot find the exact
HTTP header, it tries to find the header by substituting any wildcards in the header.

◦ If more than one header matches the user agent header sent by the browser, the first matching header is used. For example,

[Mozilla/2.0 *]

matches

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

and

[Mozilla/2.0 (compatible; MSIE 3.0B; Windows 95;1600,1280)]

but it does not match

[Mozilla/3.01b1 (Macintosh; I; PPC)]


FUNCTIONING OF BROWSER CAPABILITIES
COMPONENT (BROWSCAP.INI FILE):
◦ When a browser requests a page from your Web server, it sends some information about itself
in the HTTP user agent header of the request.
◦ The Browser Capabilities component compares this information to a list of browsers that it
keeps in a file named browscap.ini.
◦ This file also has information about each browser's abilities. The Browser Capabilities
component can then return information from the browscap.ini file for your use.
◦ This component doesn't actually know anything more about a browser than you tell it in the
browscap.ini file.
◦ It is strictly an engine for looking up already recorded capabilities. The more robust you make
your browscap.ini file, the more information you'll have available in your application. 
◦ Microsoft has provided a fairly extensive browscap.ini file. It covers browsers produced by
Microsoft, Netscape, and Oracle. It is installed in different directories based on whether you're
using Microsoft Windows 95 or Microsoft Windows NT and where your installation is.
Therefore, do a search (Start|Find|Files or Folders) for browscap.ini.
SYNTAX FOR PROPERTIES IN
BROWSCAP.INI FILE:
The "Browscap.ini" file can contain the following:

[;comments]
[HTTPUserAgentHeader]
[parent=browserDefinition]
[property1=value1]
[propertyN=valueN]
[Default Browser Capability Settings]
[defaultProperty1=defaultValue1]
[defaultPropertyN=defaultValueN]
EXAMPLE:
OUTPUT:
CONCLUSION:

Thus, ASP.NET provides a number of features for


determining the capabilities of the client making any given
request. This provides you with a means of controlling your
site's output by aliasing client targets to specific User Agent
strings within your application.
QUESTIONS

You might also like