Official Content

The WebBrowser external object allows you to handle events related to web-designed applications, which are embedded in Apple and Android platform applications.


You can find the WebBrowser object in the KB Explorer within the SD module, which is in turn located within the GeneXus module. That is to say, it is part of the Smart Devices API.


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.

In addition, this method only supports internal links via the GET method, which means that POST links are not supported.

If the WebBrowser.BeforeNavigate is not present, following a link from 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 Native Mobile application, is closed. It is very helpful to code communication between the mobile and web applications.

Input url:URL
Output None

Note: The OnClose event and the Close method only work when the Open method is used to open the browser.


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 typical navigation options (like the "back" or "refresh" actions) will not be available.

Implement a payment flow

This event is also useful for implementing 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 implemented as follows:

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

See also

HowTo: Open a Web Page in a New Browser Window from a Smart Devices Application


Generators: Android, Apple


Below you can find some precise definitions:

Embedded web view control

It 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

It is a full screen web browser with the typical navigation elements (URL, back button, refresh button, etc.), that is shown inside the application.

Last update: November 2023 | © GeneXus. All rights reserved. GeneXus Powered by Globant