This is designed to easily open a URL in a browser window, without resorting to platform-specific code. As of FWD v3.2 there is a more flexible approach called OPEN-MIME-RESOURCE. OPEN-URL may still be useful if one is simply opening a URL without regard to specific MIME type. For example, this is useful for loading .html resources.

This feature was created in task #1815 and modified in #3474.

4GL Syntax

In 4GL GUI applications, it is common to use COM Automation to load InternetExplorer for a specific URL. It is surprising that this useful feature is not built into the 4GL. FWD provides this feature via a language statement:

Prior to revision 11247 (public release v3.1 and prior), this is the syntax:

P2J-OPEN-URL <url_character_expression>.

As of revision 11247 (first public release as FWD v3.2), the syntax is now:

OPEN-URL <url_character_expression>.

In both versions the <url_character_expression> is any valid URL. Any valid character expression or Java String can be passed as input.

At this time, no checking of the URL is done. It is the application's responsibility to properly secure the input URL. It is strongly recommended to limit the URL to absolute paths and to otherwise check the entire text of the URL before submitting it.

Example code:

def var h1 as handle.

create window h1 assign title = "h1".

def var path as character format "x(256)" label "URL".
def button go1 label "Go".

form path skip go1 with frame f1 title "fh1".

enable all with frame f1 in window h1.

on "choose" of go1 in frame f1 do:
   assign path.
   message "Go " + path in window h1.

   open-url path.

view h1.

wait-for close of current-window.

FWD Implementation Details

The resulting Java code will call com.goldencode.p2j.util.WebBrowserManager.openURL(String url) or com.goldencode.p2j.util.WebBrowserManager.openURL(character url) to launch the browser. The page load will be executed on the FWD client using ThinClient.openURL(String url). This code will use driver-specific code for the launching or loading. In particular it is important to note that in some cases a browser program will be launched and in other cases the URL will be loaded into an existing browser. See below for specific.

The statement will return after the launch/load occurs. It will not block or otherwise wait for the page/browser to be closed.

This feature was implemented in task #1815.

ChUI Drivers

The ChUI drivers don't support this feature, it silently does nothing in this case.

Swing GUI

The Swing GUI driver will launch the OS helper application in case of file:/// URL or the OS default browser in all other cases if the OS desktop feature (API) is supported, otherwise it will launch a separate executable program. The command line program name for this executable is calculated as follows:

1. If browser-executable is specified in the directory, it will be honored. This value can hold a simple program name OR it can be the program name and default arguments. The first text in the entry must be the program name. If there is whitespace following the program name, any text after the whitespace is treated as the default arguments to the program. Due to this design, you may not use embedded whitespace inside the browser's program name. See the directory configuration reference for details on where to specify this value in the directory.

2. If not specified, then a platform specific browser default is used:

Platform Browser Program Default Arguments
Linux firefox n/a
MacOS open -a safari
Solaris firefox n/a
Windows iexplore.exe n/a

In addition to any default arguments, the URL is passed on the command line.


The web GUI driver does not launch a separate browser. It will simply load the URL into a new browser window in the same browser instance in which the FWD web client is already running.

The Window loads the provided URL with this JavaScript code (see, "_blank");

If a window named "_blank" does not exist, it should open new window, otherwise it will load into the existing window of that name. From the Mozilla documentation:

The open() method creates a new secondary browser window, similar to choosing New Window from the File menu. The strUrl parameter specifies the URL to be fetched and loaded in the new window. If strUrl is an empty string, then a new blank, empty window (URL about:blank) is created with the default toolbars of the main window.


If a window with the name already exists, then strUrl is loaded into the existing window.

© 2004-2017 Golden Code Development Corporation. ALL RIGHTS RESERVED.