Skip to content

Browser Events

The Browser widget has the following events associated with it:


doLayout Event


This event is invoked for every widget when the widget position and dimensions are computed.

Syntax


doLayout()

Read/Write

Read + Write

Remarks

This event is invoked for all the widgets placed inside flex containers. This event is invoked in the order in which the widgets are added to the widget hierarchy and expect the frame property of the widget is calculated and available for use within this event.

This event is used to set the layout properties of child widgets in the relation to self and peer widgets whose layout is not yet performed.

The number of times this event invoked may vary per platform. It is not recommended to write business logic assuming that this function is invoked only once when there is a change in positional or dimensional properties. This event will not trigger when transformations are applied though widget is moved or scaled or rotated from its original location.

Example


//Sample code to set doLayout event callback to a button widget.
/*This code changes the top property of button2 and makes it appear below button1.*/
myForm.button1.doLayout=doLayoutButton1;

function doLayoutButton1(){

    myForm.button2.top = myForm.button1.frame.height;
}

Platform Availability

  • iOS
  • Android
  • Windows
  • SPA

handleRequest Event


An event callback which gets invoked by the platform before browser widget navigates to a new URL.

Syntax


handleRequest()

Optional Parameters

eventobject

Optional. A unique Id that identifies the browser widget.

params

Optional. An object that identifies the url parameters as key-values pair.

Following are the parameters of the object.

originalURL [String] - Optional

Specifies the original url of the current page.

q_ueryParams[Object]_ - Optional

Specifies the dictionary containing the query parameters passed to the URL as key, values in the dictionary.

requestMethod[String] - Optional - Supported only on iOS

Specifies the request method type. Following are the available options:

  • Constants.BROWSER_REQUEST_METHOD_GET
  • Constants.BROWSER_REQUEST_METHOD_POST

header[JSObject] - Optional - Supported only on iOS

Specifies a dictionary containing all the HTTP header fields.

Read/Write

Write only

Remarks

This is useful in scenarios where the developer wants to keep track of the URLs that the browser field navigates to. For example, in a payment flow (that is, being executed inside a browser widget) on successful redirection to a payment confirmation page the developer would like to take the user to a new native form.

On iOS platform, whenever handleRequest is set to browser and request comes to browser widget to load the url or.html, then before loading the content, handle request is called. Also, whenever a user selects any hyperlink then also handleRequest is called.

The return value from this function determines how the browser widget handles the original request. If a false value is returned, then the browser widget continues navigation to the original URL and if the true value is returned then the developer has to handle the request.

The handleRequest event is not triggered for the web pages that change the HTML content dynamically within the same page. For example, SPA apps.

The handleRequest event is not triggered for the bookmark navigation on the same page in the Android platform.

Example


//The below function is the call back for handleRequest event
function handleRequestCallback(browserWidget, params) {
    voltmx.print("handleRequest event triggered");
    voltmx.print("Original URL" + params["originalURL"]);
    voltmx.print("Request Method" + params["requestMethod"]);
    voltmx.print("Header" + JSON.stringify(params["header"]));
    //Ignore this request and continue loading other URLs.
    return false;
    //If false is returned, platform will load the originalurl in the browser widget.
}

frmobj.brw1.handleRequest = handleRequestCallback

Platform Availability

  • iPhone
  • iPad
  • Android
  • Windows

onFailure Event


An event callback which gets invoked by the platform when the given URL fails to load. The behavior of this callback has changed in Iris 7.3 and may require changes to your code, particularly the addition of the errorObject parameter.

Syntax


onFailure()

Optional Parameters

eventObject

Required. A unique Id that identifies the browser widget.

errorObject

Required. An object that provides details for the error. See Remarks for possible values. This value is new in Iris 7.3.

Read/Write

Read + Write

Remarks

The errorObject is a dictionary object that has these predefined keys:

  • errorCode - the VoltMX error code
  • errorMessage – error message
  • errorDetails – platform specific error details
  • httpStatusCode - Actual HTTP status code. For iOS this will be set to -1.

All errors reported by this callback:

Error Code Error Message Android Windows iOS
1000 Unknown error while connecting. The platform cannot differentiate between network errors, The platform reports error code 1000 by default. ERROR_UNKNOWN Unknown InternalServerError OperationCanceled UnexpectedClientError UnexpectedStatusCode ErrorUnknown
1001 Cannot connect to host. ERROR_CONNECT ERROR_HOST_LOOKUP CannotConnect, ConnectionAborted, ConnectionReset, Disconnected, ServiceUnavailable ServerUnreachable NotFound, HostNameNotResolved ErrorCannotConnectToHost ErrorDNSLookupFailed ErrorCannotFindHost, ErrorRedirectToNonExistentLocation
1002 Input Stream Related Errors ERROR_IO   ErrorRequestBodyStreamExhausted
1003 Permission Related ERROR_AUTHENTICATION ERROR_PROXY_AUTHENTICATION ERROR_UNSUPPORTED_AUTH_SCHEME Unauthorized PaymentRequired UseProxy Forbidden ProxyAuthenticationRequired ErrorUserAuthenticationRequired
1004 Invalid input url ERROR_BAD_URL ERROR_UNSUPPORTED_SCHEME RequestEntityTooLarge RequestUriTooLong ErrorBadURL, ErrorUnsupportedURL
1005 Invalid method provided   MethodNotAllowed NotImplemented  
1006 File Errors ERROR_FILE ERROR_FILE_NOT_FOUND   ErrorFileDoesNotExist, ErrorFileIsDirectory, ErrorNoPermissionsToReadFile, ErrorDataLengthExceedsMaximum
1007 Device Connectivity related issues     ErrorNetworkConnectionLost, ErrorNotConnectedToInternet ErrorDataNotAllowed ErrorCallIsActive ErrorInternationalRoamingOff
1008 Request failed.   BadRequest Conflict ExpectationFailed PreconditionFailed  
1009 Invalid Server Response   ErrorHttpInvalidServerResponse  
1010 Request timed out. ERROR_TIMEOUT RequestTimeout, Timeout  
1011 User Canceled     ErrorBadServerResponse ErrorCannotParseResponse ErrorCannotDecodeRawData, ErrorCannotDecodeContentData ErrorBadServerResponse
1012 Redirection related Errors ERROR_REDIRECT_LOOP HttpsToHttpOnRedirection, HttpToHttpsOnRedirection, MovedPermanently RedirectFailed SeeOther TemporaryRedirect UnexpectedRedirection ErrorHTTPTooManyRedirects
1013 Too many requests during this load ERROR_TOO_MANY_REQUESTS    
1014 User canceled authentication     ErrorUserCancelledAuthentication
1015 App transport security requires secure connection     ErrorAppTransportSecurityRequiresSecureConnection
1016 Resource related Errors   Found Gone MultipleChoices NotModified RequestedRangeNotSatisfiable LengthRequired NotAcceptable UnsupportedMediaType ErrorResourceUnavailable, ErrorZeroByteResource
1018 SSL related error ERROR_FAILED_SSL_HANDSHAKE CertificateCommonNameIsIncorrect, CertificateContainsErrors, CertificateExpired, CertificateIsInvalid, CertificateRevoked, CertificateRevoked ErrorSecureConnectionFailed,  ErrorServerCertificateHasBadDate,  ErrorServerCertificateUntrusted,  ErrorServerCertificateHasUnknownRoot,  ErrorServerCertificateNotYetValid,  ErrorClientCertificateRejected,  ErrorClientCertificateRequired,  ErrorCannotLoadFromNetwork

This event is also not called when htmlString is set to the web widget.

Example


// This function is the callback for the onFailure event that checks for iOS native error -999
function onFailureCallback(eventObj, error) {
    if (error.errorCode !== 1011) { 
        // native error -999 is mapped to error 1011.
        voltmx.print("Unable to display report.");
    }
}
frmBrowser.myBrowser.onFailure=onFailureCallback;               

Platform Availability

  • iOS
  • Android
  • Windows

Not available on SPA


onPageFinished Event


This event is sent when a page is finished loading.

Syntax


onPageFinished (eventobject, params)

Parameters

eventobject

Optional. A unique Id that identifies the browser widget.

params

Optional. An object that identifies the url parameters as key-values pair. See Remarks for possible values.

Remarks

The following are the parameters of the params object.

originalURL [String] - Optional

Specifies the original url of the current page.

queryParams[Object] - Optional

Specifies the dictionary containing the query parameters passed to the URL as key, values in the dictionary.

Example


Form2.brw1.onPageFinished = onPageFinishedCallback;

function onPageFinishedCallback(eventobject, params) {

    voltmx.print("The eventobject is: " + eventobject + "@@@@ params are: " + params);
}

Platform Availability

  • iOS
  • Android
  • Windows

onPageStarted Event


This event is sent when a page starts loading.

Syntax


onPageStarted (eventObject, params)

Parameters

eventObject

Optional. A unique Id that identifies the browser widget.

params

Optional. An object that identifies the url parameters as key-values pair. See Remarks for possible values.

Remarks

The following are the parameters of the params object.

originalURL [String] - Optional

Specifies the original url of the current page.

queryParams[Object] - Optional

Specifies the dictionary containing the query parameters passed to the URL as key, values in the dictionary.

Example


Form2.brw1.onPageStarted = onPageStartedCallback;

function onPageStartedCallback(eventobject, params) {

    voltmx.print("The eventobject is: " + eventobject + "@@@@ params are: " + params);
}

Platform Availability

  • iOS
  • Android
  • Windows

onProgressChanged Event


The onProgressChanged callback event shows you the progress of the page loading in the Browser Widget. The platform invokes the event when the page is loading.

Syntax


onProgressChanged

Read/Write

Read + Write

Remarks

When you set the onProgressChanged event in the Browser Widget, the progress value of the loading page is passed as a parameter to the callback.

Example


// The following function is the callback for onProgressChanged event
function onProgessChangedCallback(progress) {
    alert("Progress value -" + progress);
}

frmBrowser.myBrowser.onProgressChanged = onProgessChangedCallback;

Platform Availability

  • Available in the IDE
  • Available only on the Android platform.