Omnis Technical Note TNWE0003
How to redirect an HTML page depending on the browser and the platform
For Omnis Studio
By Rudolf Bargholz
Due to its publication date, this technote contains information which may no longer be accurate or applicable on one or more of the platforms it refers to. Please refer to the index page which may contain updated information.
The following tech note will be useful for those who use the Omnis Web Client and have to redirect their Web Form page depending on the browser the client is using.
When using the Omnis Web Client, you have to embed a reference to the web client object code in an HTML page. As the object code for Netscape and Internet Explorer object differs, one is normally forced to create two HTML pages for one web form, one that uses the Netscape object code format and one that uses the format for Internet Explorer. To complicate matters, the Internet Explorer on the Mac needs to use the Netscape object code format. What would be ideal is, if one opens an HTML page in the browser, the browser recognizes what browser the client is using, Netscape or Internet Explorer, what platform the browser is running on, and then redirects the window's HTML location to the required HTML page. Another issue is to open the browser window with no toolbar or menu items visible
A couple of points regarding the example code
If one removes the preceding "//", e.g. in the line
one effectively removes the comment and the line will be executed.
2) For debug purposes I have used the following code in the BODY section
of the HTML:
All these lines of code do is write text to the browser. The text written
These lines can be deleted from the HTML text when deploying the code.
When deploying the code, one has to uncomment the line BODY section
open the URL stored in the variable "BrowserPlatformURL".
3) The variable "BrowserPlatformURL" is filled with the following line
var BrowserPlatformURL = getPage();
var BrowserName = getBrowser();
var PlatformName = getPlatform();
var NetscapeURL = "netscape.htm"; // enter your Netscape URL here
var ExplorerURL = "explorer.htm"; // enter your IE URL here
The variable "BrowserName" is filled by calling a function called "getBrowser()".
This function will return "IE" for the Internet Explorer or "NS" for Netscape.
The variable "PlatformName " is filled by calling a function called "getPlatform()". This function will return "M" for the Mac platform, "W" for the Windows platform or "L" for Linux platform.
The variables "NetscapeURL" and "ExplorerURL" can be used to store the URL of the respective Netscape or Internet Explorer Omnis Web Client HTML pages, e.g.
var NetscapeURL = "http://www.mytest.com/IE.htm"; // enter your Netscape URL here
var ExplorerURL = "http://www.mytest.com/NS.htm"; // enter your IE URL here
The function "getPage()" will either return
the text "ERROR" if an unsupported browser is used or the platform is not supported.
If a URL is returned, the function
will open that URL in the current browser.
window.open(address, "NewWindow", option )
a) 'address'is the URL to be opened
b) ' "NewWindow" ' tells the command to open a new window
c) 'option' is a list of parameters that are to be passed to the to be opened window, telling it what it is to display and what not to
} The function can be called via an HREF, e.g. ...