|
Sybernet / Supplied Packages Reference
Release 3.00 Feb 22, 2003 |
|
The NAVIGATOR package provides subprograms for interrogating information about the browser used to connect to Sybernet. Normally, you would use JavaScript to retrieve this information, but there are times when having this information available to your PL/SQL stored procedure can eliminate a lot of extra work on your part.
The most useful function in this package is navigator.userAgent because all of the functions in this package are derived from this string. The appName function, for example, correctly returns 'Navigator' if no other compatible browser is found.
One draw-back of these functions is that they rely on Sybernet to store the HTTP_USER_AGENT environment variable when you connect to Oracle. If you do not connect with Sybernet or SQLPlus, these functions will return "undefined." If you start your session with Netscape Navigator and then switch to Safari without first logging off, the information returned will correspond to Netscape Navigator.
The other draw-back is that this usage is known as Browser Detection and is not fool-proof because browser manufactures like to put misleading information in the userAgent string. There is a fairly good write-up of Browser Detection and Cross Browser Support at Netscape DevEdge, but as often as the userAgent string changes so do links and this one is no doubt dead by the time you read this. The examples on object detection (the preferred model) are quite interesting since most of them illustrate how not to do this.
NAVIGATOR defines the following constants:
/* ** miscellaneous */ UNDEFINED constant varchar(30) := 'undefined'; /* ** appName */ KONQUEROR constant varchar(30) := 'Konqueror'; SAFARI constant varchar(30) := 'Safari'; OMNIWEB constant varchar(30) := 'OmniWeb'; OPERA constant varchar(30) := 'Opera'; WEBTV constant varchar(30) := 'WebTV'; ICAB constant varchar(30) := 'iCab'; MSIE constant varchar(30) := 'Microsoft Internet Explorer'; NETSCAPE constant varchar(30) := 'Netscape'; /* ** platform */ LINUX constant varchar(30) := 'Linux'; UNIX constant varchar(30) := 'Unix'; MACINTOSH constant varchar(30) := 'MacPPC'; MAC constant varchar(30) := 'MacPPC'; WINDOWS constant varchar(30) := 'Windows'; /* ** product */ GECKO constant varchar(30) := 'Gecko';
| Subprogram | Description |
|---|---|
appCodeName function |
A string specifying the code name of the browser. |
appName function |
A string specifying the name of the browser. |
appVersion function |
A string specifying version information for the Navigator. |
language function |
A string representing the installed language for this Navigator. |
platform function |
A string representing the client's platform. |
product function |
Gecko is the signature of all Netscape Gecko browsers. |
userAgent function |
A string representing the value of the user-agent header sent in the HTTP protocol from client to server. |
vendor function |
Vendor describes the vendor or brand. Note that for Mozilla, the Vendor is not present. |
vendorSub function |
VersionSub describes the Vendor's version number. |
version function |
A string specifying the version number for this Navigator. |
Mostly harmless.
HTTP.NAVIGATOR.APPCODENAME RETURN VARCHAR2;
None.
A string specifying the code name of the browser.
The following example illustrates how to call appCodeName:
select http.navigator.appCodeName from dual; APPCODENAME -------------------------------------------------- Mozilla
appName returns the name of your browser. Since the string returned is case-sensitive, you may wish to use the defined constants in this package.
HTTP.NAVIGATOR.APPNAME RETURN VARCHAR2;
None.
A string specifying the name of the browser.
The following example illustrates how to call appName:
select http.navigator.appName from dual; APPNAME -------------------------------------------------- Netscape
appVersion returns the information from userAgent after the appCodeName. If you need both the major and minor release numbers (for example), then appVersion is the desired string.
HTTP.NAVIGATOR.APPVERSION RETURN VARCHAR2;
None.
A string specifying version information for the Navigator.
The following example illustrates how to call appVersion:
select http.navigator.appVersion from dual; APPVERSION -------------------------------------------------- 4.61 (Macintosh; U; PPC)
I'm not sure I would use this function to determine the supported language since the language information is missing in some browsers.
HTTP.NAVIGATOR.LANGUAGE RETURN VARCHAR2;
A string representing the installed language for this Navigator.
The following example illustrates how to call language:
select http.navigator.language from dual; LANGUAGE -------------------------------------------------- en
This function determines the platform this browser is running from. Since the returned string is case-sensitive, you may prefer to use the platform constants defined in this package.
HTTP.NAVIGATOR.PLATFORM RETURN VARCHAR2;
None.
A string representing the client's platform.
The following example illustrates how to call platform:
select http.navigator.platform from dual; PLATFORM -------------------------------------------------- MacPPC
This function returns the complete HTTP_USER_AGENT environment variable. Note that this string is null if you attempt to use this function against a process that did not connect with Sybernet.
HTTP.NAVIGATOR.USERAGENT RETURN VARCHAR2;
None.
A string representing the value of the user-agent header sent in the HTTP protocol from client to server.
The following example illustrates how to call userAgent:
select http.navigator.userAgent from dual; USERAGENT -------------------------------------------------- Mozilla/4.61 (Macintosh; U; PPC)
This function returns the major version number of your browser; for example, if appVersion is 4.61 (Macintosh; U; PPC), then this function returns 4.
HTTP.NAVIGATOR.VERSION RETURN VARCHAR2;
None.
A string specifying the version number for this Navigator.
The following example illustrates how to call version:
select http.navigator.version from dual VERSION -------------------------------------------------- 4
The string Gecko is the unique identifier for all Gecko based browsers. This is the single most important aspect of the user-agent string to detect in order to properly report Gecko usage
HTTP.NAVIGATOR.PRODUCT RETURN VARCHAR2;
None.
Gecko is the signature of all Netscape Gecko browsers.
The following example illustrates how to call product:
select http.navigator.product from dual PRODUCT -------------------------------------------------- Gecko
The value of the Vendor/Version portion of the Gecko user-agent string is not specified by the Mozilla user-agent string reference and can be any value determined by the organization responsible for creating each particular browser based upon Gecko.
Netscape branded browsers based upon Netscape Gecko will contain the string Netscape following the Gecko/CCYYMMDD portion of the user-agent string. For example, Netscape 6.x browsers will contain Netscape6/6.x following the Gecko/CCYYMMDD and Netscape 7.x browsers will contain Netscape/7.x following Gecko/CCYYMMDD.
AOL-branded Gecko-based browsers based upon Netscape Gecko will contain the string AOL following the Gecko/CCYMMDD portion of the user-agent string. For example, AOL agents based upon Netscape Gecko will contain AOL/7.0 or AOL/8.0 depending upon their version.
CompuServe branded browsers based upon Netscape Gecko will contain the string CS 2000 7.0 following the Gecko/CCYMMDD portion of the user-agent string.
HTTP.NAVIGATOR.VENDOR RETURN VARCHAR2;
None.
A string specifying the vendor name for this Navigator.
The following example illustrates how to call vendor:
select http.navigator.vendor from dual VENDOR -------------------------------------------------- Netscape
Version describes the Vendor's version number.
HTTP.NAVIGATOR.VENDORSUB RETURN VARCHAR2;
None.
The version number corresponding to this vendor.
The following example illustrates how to call vendorSub:
select http.navigator.vendorSub from dual VENDORSBUB -------------------------------------------------- 7.0