Method XbpHTMLViewer2():navigate() Foundation
Navigates to a specified URL.
:navigate( <coURLOrRequestMessage> ) --> oAsyncResult
A AsyncResult() object which can be used to wait until the navigation is finished and for checking the operation's result.
The method navigates to the specified URL or document. The document is loaded into the XbpHTMLViewer2 object and displayed.
The navigation is performed asynchronously and subsequent operations on the content will fail until the requested resource has been loaded and the browser has finished navigation. Examples for this are the methods :executeScript() and :print() which both fail while a navigation is in progress.
:navigate() returns a AsyncResult() object which can be used to wait until the navigation is finished and for checking the operation's result. In case an error occurred, the :osCode member of the Error object (see AsyncResult():error()) contains a WebView2-specific error code indicating the reason for the failure. See here for a list of the possible error codes: https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2weberrorstatus?view=webview2-winrt-1.0.3240.44.
Example for parameterizing a navigation request
// This example navigates to a webpage using a parameterized request with
// the following data:
// - a cookie for switching the webpage to a certain language
// - a "Authorization" header for specifying user/application credentials
#include "xbp.ch"
PROCEDURE Main()
LOCAL oDlg
LOCAL oXbp
LOCAL oRequestMessage
SET CHARSET TO ANSI
// Create a form for hosting the HTML viewer object
oDlg := XbpDialog():new( AppDesktop() )
oDlg:taskList := .T.
oDlg:create( ,,, {640,480} )
CenterControl( oDlg )
// Create the HTML viewer object in the form's content area
oXbp := XbpHTMLViewer2():new( oDlg:drawingArea )
oXbp:layoutAlign := XBPLAYOUT_LEFT + XBPLAYOUT_TOP + XBPLAYOUT_RIGHT + XBPLAYOUT_BOTTOM
oXbp:create( ,, {10,10}, {600,420} )
// Parameterize the request with a cookie and a HTTP header
// with user/application credentials
oRequestMessage := HttpRequestMessage():new( "https://www.example.com" )
oRequestMessage:setCookie( "userlang", "de" )
oRequestMessage:addHeader( "Authorization", "Basic ZGVtbzpkZW1v" )
// Navigate to the webpage using the parameterized request
oXbp:navigate( oRequestMessage )
oDlg:showModal()
oDlg:destroy()
RETURN
PROCEDURE AppSys()
// Prevent creation of the default console window
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.