WebBrowser external object

Official Content
This documentation is valid for:

The WebBrowser external object allows you to handle events related to web-designed applications which are embedded in a Smart Device application.



Through this document we will be using some names that require a precise definition, so that we can later use them more loosely.

Embedded web view control: Is a control that is shown inside the Panel's layout, and can show a web page. It can be a read-only attribute, variable or SDT member based on the Component or HTML domains.

Inline web browser: Is a full screen web browser with the tipical navigation elements (URL, back button, refresh button, etc.), that is shown inside the application.


Open method

Opens an inline web browser, displaying the given URL. This method replaces the OpenInBrowser method of Interop external object.

Input url:URL
Output None

Close method

Closes the inline web browser.

Input None
Output None


BeforeNavigate event

This event lets you capture -before they happen- navigation events started from an embedded web view control, so that you can decide how to handle this navigation.

Note that this event is not triggered from the inline web browser, but just from an embedded web view control.

If the WebBrowser.BeforeNavigate is not present, following a link from an an embedded web view control will always open the inline web browser. The reason for this is that the embedded web view control has no navigation controls (like the "back" or "refresh" buttons), required for a correct navigation experience.

When the WebBrowser.BeforeNavigate is present, you can control if a link is opened in the same embedded web view control or if it should open an inline web browser.

This event receives the URL that will be opened, and an in-out parameter that indicates if the navigation has been handled. If you set the &handled variable to True, then the application will not follow the link, because it assumes that it has been handled in the event. If you set it to False, then the navigation is handled as usual and the application will open an inline web browser to show the &url parameter.

Input url:URL
In-out handled:Boolean
Output None

OnClose event

This event is triggered when the inline web browser, opened within a Smart Devices application, is closed. It is very helpful to code communication between the mobile and web applications.

Input url:URL
Output  None

Examples for the BeforeNavigate event

Navigating inside the embedded web view control

If you want to navigate inside the embedded web view control (say you have a &Component variable), the following code can be used:

Event GeneXus.SD.WebBrowser.BeforeNavigate(&Url, &Handled)
    &Component = &Url // assign the new URL to the variable in the form
    &Handled = true

Keep in mind that the tipical navigation options (like the "back" or "refresh" actions) will not be available.

Implement a payment flow

This event is also usefull to implement a payment flow, where the web page acts like some kind of wizard with several steps, and after finishing it calls some well known callback URL to finish the payment process.

This can be implemeted as follows:

Event GeneXus.SD.WebBrowser.BeforeNavigate(&Url, &Handled)
    if &Url = &callbackURL
    &Handled = true // always force navigation inside the embedded web view

See also


Generators  Apple, Android