Sometimes, you may want your application to respond in different ways to different browsers. In this case, you can use the W$BROWSERINFO library routine to determine the version and name of the requesting browser, that is, the one that will be hosting the COBOL application.
CALL this routine using the following syntax:
CALL "W$BROWSERINFO" USING BROWSERINFO-DATA
BROWSERINFO-DATA Group item as follows:
01 BROWSERINFO-DATA. 03 USER-AGENT-STRING PIC X(50). 03 BROWSER-MAJOR-VERSION PIC X COMP-X. 03 BROWSER-MINOR-VERSION PIC X COMP-X.
BROWSERINFO-DATA is found in the COPY library "ACUCOBOL.DEF."
Upon return from W$BROWSERINFO, all of the data elements contained in BROWSERINFO-DATA are filled in. If you call W$BROWSERINFO and the COBOL application is not running in a Web browser via the Web runtime, the first field is set to spaces and the last two fields are set to zero. The BROWSERINFO-DATA fields have the following meaning:
|USERAGENT-STRING||The browser's user_agent field. This contains the name of the browser software as it is sent to the HTTP server. It may also contain version numbers, product name, and operating system name. Netscape browsers set the first seven characters of this field to "Mozilla". Microsoft Internet Explorer sets this field to "Microsoft Internet Explorer".|
|BROWSERMAJORVERSION||The major version number reported by the browser. This is not the same as the major version number displayed in the browser's "About" screen. For example, both Netscape and Internet Explorer put "0" in this field.|
|BROWSER-MINOR-VERSION||The minor version number reported by the browser. This is not the same as the minor version number displayed in the browser's "About" screen. For example, both Netscape and Internet Explorer put "9" in this field.|