WebView

A JavaScript abstraction of the underlying WebKit WebView.

Members

active


Whether the current WebView is active. A value of true indicates that the WebView is active, false indicates otherwise.

allowAllPropertyChangedEvents


Indicates whether property change events are enabled in the WebView. A value of true indicates that property change events are enabled in the WebView, false indicates otherwise.

allowAllWebEvents


Indicates whether web events are enabled in the WebView. A value of true indicates that web events are enabled in the WebView, false indicates otherwise.

allowQnxObject


Indicates whether the WebView can access QNX objects, such as Persistent Publish/Subscribe (PPS) objects. A value of true indicates that QNX objects can be accessed, false indicates otherwise.

allowsAnyPropertyChangedEvents


(Read-only) Indicates whether any events are sent for any property changes in the WebView. A value of true indicates that events are sent when a property changes in the WebView, false indicates otherwise.

allowsAnyWebEvents


(Read-only) Indicates whether the WebView is allowed to send webevents.

autoDeferNetworkingAndJavaScript


Indicates whether a WebView can retrieve a network connection or JavaScript when the app is in the foreground. A value of true indicates that retrieval is deferred until the application is in the foreground, false indicates otherwise.

backgroundColor


The background color of the WebView.

consoleLogEnabled


Whether the console logs are enabled for the WebView. A value of true indicates that logs are available for the WebView, false indicates otherwise.

currentContext


(Read-only) A JSON-formatted string with the current context (i.e., alt, src, etc.) of the WebView.

defaultFontSize


The font size of the WebView as a numeric value that's used as default on the WebView.

devicePixelRatio


The device pixel ratio of the WebView.

enableCrossSiteXHR


Indicates whether to allow cross-domain XHR long-polling or XHR streaming. A value of true indicates that the cross-domain XHR is enabled, false indicates otherwise.

enableDialogRequestedEvents


Indicates whether events requested by a dialog window in the WebView are enabled. A value of true indicates that events can be requested by a dialog window in the WebView, false indicates otherwise.

enableInProcessWebInspector


Indicates whether the in-process Web Inspector is enabled for the WebView. A value of true indicates that the in-process Web Inspector is enabled, false indicates otherwise.

enableJavaScript


Indicates whether JavaScript is enabled for the WebView. A value of true indicates that JavaScript is enabled, false indicates otherwise.

enableWebInspector


Indicates whether Web Inspector is enabled for the WebView. A value of true indicates that the Web Inspector is enabled, false indicates otherwise.

extraHttpHeaders


Extra HTTP header information as JSON-formatted data. You can use this property to allow a WebView to set a JSON-formatted key value list of headers, and retrieve a JSON key-value pair. The value you set or retrieve with this property is a JSON-formatted string.

fullScreenVideoCapable


Indicates whether full-screen video playback is available. A value of true indicates that full-screen playback is enabled, false indicates that it's disabled.

id


(Read-only) The ID of the WebView.

javaScriptInterruptTimeout


The number of milliseconds before an interrupt timeout occurs for JavaScript in the WebView.

jsScreenWindowHandle


(Read-only) The unique identifier for the WebView application screen.

keyboardVisible


Indicates whether the keyboard is enabled for the WebView. A value of true indicates that the keyboard is enabled, false indicates otherwise.

(inner, readonly) originalLocation


(Read-only) The original URL for the current WebView.

overScrollColor


Indicates whether it's allowed to scroll past the boundaries in the WebView. A value of true indicates that the overscrolling is allowed, false indicates that overscrolling isn't allowed.

pluginsEnabled


Whether plugins are enabled for the WebView. A value of true indicates that the plugins are enabled for the WebView, false indicates otherwise.

processId


(Read-only) The process id of the WebView.

sensitivity


The sensitivity mode of the WebView. Can be one of the following string values:
  • SensitivityAlways
  • SensitivityTest
  • SensitivityNoFocus
  • SensitivityNever
  • SensitivityFullscreen

setFileSystemSandbox


Indicates whether the filesystem sandbox is enabled for the WebView. A value of true indicates that the filesystem sandbox is enabled, false indicates otherwise.

status


(Read-only) The status of the WebView.

title


(Read-only) The title of the WebView.

uiWebView


The UI WebView of the current WebView.

url


The fully qualified URL currently loaded in the WebView.

userAgent


The user-agent string of the WebView.

visible


The current visibility of the WebView. A value of true indicates that the WebView is visible on the screen, false indicates otherwise.

windowGroup


(Read-only) The windowGroup that the WebView belongs to.

zOrder


The z-order of the WebView in comparison to other WebViews. Z-order indicates the order in which two-dimensional objects overlap with each other.

Methods

addKnownSSLCertificate(url, certificateInfo)


Allows the WebView to add a known SSL Certificate to its stored list of known certificates. This allows WebViews to remember certificate exceptions.

Parameters:

Name Type Description
url String The url of the website for which we wish to add a known certificate.
certificateInfo String The certificate info passed from the SSLHandshakingFailed event.

addMultipleSSLCertificates(urlInfo)


Allows the WebView to add known SSL Certificates to its stored list of known certificates. This function also allows WebViews to retain certificate exceptions.

Parameters:

Name Type Description
urlInfo Array The array of URL and SSL Certificate information. The information is specified as JSON objects you want to add.

Example

{String} url, {JSON String} certInfo
 webview.addMultipleSSLCertificates([(url, certInfo),..])

addOriginAccessWhitelistEntry(sourceOrigin, destination, allowSubdomainsopt)


Allows the WebView to add a whitelist to facilitate access between two origins. This function allows cross-origin communication that isn't otherwise possible.

Parameters:

Name Type Attributes Default Description
sourceOrigin String The URI of the source where a network request is created. Use local:// for local access.
destination String The URI of the destination of a network request.
allowSubdomains Boolean <optional>
False Specifies whether access between subdomains between source and destination origins are allowed. A value of true indicates that access between subdomains between different origins is allowed.

allowGeolocation(origin)


Allows the WebView to access geolocation information for a specific site. This function suppresses any notifications from the WebKit.

Parameters:

Name Type Description
origin String The domain of the website that allows access to the geolocation.

allowNotifications(origin)


Allows the WebView to post notifications. This function suppresses any notifications from WebKit.

Parameters:

Name Type Description
origin String The domain of the website.

allowUserMedia(evtId, cameraName)


Allow the WebView to access user media from the specified camera.

Parameters:

Name Type Description
evtId Number The ID of the event.
cameraName String The camera to be used for capturing/recording.

allowWebEvent(eventName)


Allows web events, which requires explicit enabling.

Parameters:

Name Type Description
eventName String The name of the event.

allowWebInspection()


Indicates whether the Web Inspector is enabled for the WebView. A value of true indicates that the Web Inspector is enabled, false indicates that the Web Inspector is disabled.

animateWindowLocation(curve, duration, startX, startY, endX, endY, callback)


Animates the window's specified position.

Parameters:

Name Type Description
curve String The type of curve. It can be of the following values:
  • Linear
  • EaseInCurve
  • EaseOutCurve
duration Float The timeframe of the animation (fractional seconds).
startX Integer The starting horizontal position.
startY Integer The starting vertical position.
endX Integer The ending horizontal position.
endY Integer The ending vertical position.
callback Object The function to call when the animation completes.

captureContents(evtId, contentsRect, destinationSize, callback)


Capture a certain amount of content in the specified rectangle area of the WebView.

Parameters:

Name Type Description
evtId Number The event ID to capture the content for.
contentsRect JSON The rectangle area of the contents used for capture.
destinationSize JSON The size of the contents you want to save.
callback callback The callback function you want to call after the function completes.

Example

function runmycallback(base64PNGImageString)
{
    document.getElementById("something").src = 'data:image/png;base64,' + base64PNGImageString;
}

var contentsRect = JSON.stringify({x: 0, y: 0, width: screen.width, height: screen.height});
destinationSize = JSON.stringify({width: screen.width, height: screen.height});
webview.captureContents(contentsRect, destinationSize, runmycallback);

chooseFileResponse(waitHandleID, pathopt)


Uses a waitable object for chooseFile event handler.

Parameters:

Name Type Attributes Default Description
waitHandleID String The ID of the wait handle to the object.
path String <optional>
"" The encoded path to the target file.

continueSSLHandshaking(streamId, SSLAction)


When a SSLHandshakingFailed event is triggered and causes the SSL handshake to pause. This call indicates how to handle the handshake.

Parameters:

Name Type Description
streamId Number The SSL stream identifier from the SSLHandshakingFailed event.
SSLAction String The SSLAction can be one of these values:
  • SSLActionTrust - Continue with the handshake protocol and accept client certificates.
  • SSLActionReject - Fail the handshake and refuse to accept the server certificates.
  • SSLActionNone - Ignore the error and continue with the handshake.

createTouchInputSession()


Creates a touch input session for the capacitive keyboard.

delete(onCompleteopt)


Deletes the underlying native WebView implementation.

Parameters:

Name Type Attributes Description
onComplete callback <optional>
The callback to call after the function call completes.

destroy(onCompleteopt)


Destroys the underlying native implementation of the WebView. To remove the WebView completely, delete it after this call.

Parameters:

Name Type Attributes Description
onComplete callback <optional>
The callback to call when this function completes.

destroyTouchInputSession()


Destroys the touch input session for the capacitive keyboard.

dialogResponse(waitHandleID, okText, username, password)


Uses waitable object for dialog responses.

Parameters:

Name Type Description
waitHandleID String The ID of waitHandle for the dialog.
okText String The text response from the dialog.
username String The username response from the dialog.
password String The password response from the dialog.

dialogResponse requestCurrentContextUpdate()


Request for the current context update.

disallowGeolocation(origin)


Disallows the current WebView from accessing geolocation information from the specified domain.

Parameters:

Name Type Description
origin String The domain of the website disallows geolocation access.

disallowNotifications(origin)


Disallows the WebView from posting notifications for a specific site. This function also suppresses any notifications from WebKit.

Parameters:

Name Type Description
origin String The domain of the website.

disallowUserMedia(evtId)


Disallow the WebView from accessing user media from the specified camera.

Parameters:

Name Type Description
evtId Number The ID of the event.

disallowWebEvent(eventName)


Disallows a web event, which has been explicitly enabled.

Parameters:

Name Type Description
eventName String The name of the event.

downloadURL(url)


The URL for the native implementation to download from.

Parameters:

Name Type Description
url String The URL to download from.

emit(eventType, args, sync)


Dispatches an event of the provided type with the given arguments to all registered listeners.

Parameters:

Name Type Description
eventType String The native event to emit. Only the following events can be emitted or the method fails silently.
The event type can be one of the following strings:
  • ContentRendered
  • ContextMenuCancelEvent
  • Created
  • Destroyed
  • DocumentLoadCommitted
  • DocumentLoaded
  • DocumentLoadFinished
  • DialogRequested
  • JavaScriptCallback
  • JavaScriptResult
  • InvokeRequestEvent
  • LocationChange
  • NetworkError
  • PropertyActiveEvent
  • PropertyBackgroundColorEvent
  • PropertyCanGoBackEvent
  • PropertyCanGoForwardEvent
  • PropertyCertificateInfoEvent
  • PropertyContentRectangleEvent
  • PropertyCurrentContextEvent
  • PropertyEnableWebInspectorEvent
  • PropertyEncryptionInfoEvent
  • PropertyFaviconEvent
  • PropertyHistoryListEvent
  • PropertyHistoryPositionEvent
  • PropertyJavaScriptInterruptTimeoutEvent
  • PropertyLoadProgressEvent
  • PropertyLocationEvent
  • PropertyOriginalLocationEvent
  • PropertyScaleEvent
  • PropertyScrollPositionEvent
  • PropertySecureTypeEvent
  • PropertyStatusEvent
  • PropertyTitleEvent
  • PropertyTooltipEvent
  • PropertyVisibleEvent
  • PropertyWebInspectorPortEvent
  • PropertyViewportEvent
  • PropertyZOrderEvent
args Array.<Object> The array of objects to be passed to the event.
sync Boolean A boolean value indicating whether the event should be synchronized. A value of true indicates to synchronize the event, false indicates otherwise.

enableStringPatternMatching(eventName)


Enable string pattern matching.

Parameters:

Name Type Description
eventName String The name of the event.

executeJavaScript(js, inIsolatedWorldopt, onCompleteopt)


Executes JavaScript in the context of the WebView.

Parameters:

Name Type Attributes Default Description
js String The JavaScript expression to be executed.
inIsolatedWorld boolean <optional>
false Whether to run JavaScript in isolated context. A value of true indicates to in isolated context. The default is false/
onComplete callback <optional>
The callback to be invoked when the destruction call is complete.

handleContextMenuResponse(action)


Based on the given action, indicates to the native implementation to handle the context-menu response.

Parameters:

Name Type Description
action String The identifier of the context-menu action to be handled.

hasKnownSSLCertificate(url)


Allows the WebView to add a known SSL Certificate to its stored list of known certificates. This allows WebViews to remember certificate exceptions.

Parameters:

Name Type Description
url String The url of the website for which we wish to add a known certificate.

initialize(orientation)


Initializes the WebView with an orientation.

Parameters:

Name Type Description
orientation Number The orientation you want to initialize. You can use integer values, such as 0, 90, -90, etc.

isGeolocationAllowed(origin)


Determine whether the specified domain is allowed to access geolocation information. This function suppresses any notifications from WebKit.

Parameters:

Name Type Description
origin String The domain of the website that disallows geolocation access.

isVideoFullScreen()


Returns the boolean value for the property VideoFullScreen of the WebView

isWebEventAllowed(eventName)


Determines if an event has been explicitly enabled.

Parameters:

Name Type Description
eventName String The name of the event.

knownSSLCertificates()


Shows all of the known SSL Certificates of the WebView.

log(errorMsg)


Logs the error message of the WebView.

Parameters:

Name Type Description
errorMsg String The error message you want to log.

notifyApplicationOrientationDone()


Notifies the native implementation that the WebView has completed its rotation.

notifyContextMenuCancelled()


Notifies native implementation that the context menu has been dismissed.

notifyDataReceived(streamId, responseCode, value)


Notifies the native implementation of WebView that data was received.

Parameters:

Name Type Description
streamId Number The identifier of the stream that has been opened.
responseCode String The response to the opening of it.
value String The value you wish to send as a notification to the native implementation of WebView.

notifyDone(streamId, responseCode, value)


Notifies native implementation that everything has completed.

Parameters:

Name Type Description
streamId Number The identifier of the stream that has been opened.
responseCode String The response to the opening of it.
value String The value you wish to send as a notification to the native implementation of WebView.

notifyHeaderReceived(streamId, responseCode, value)


Notifies the native implementation of WebView that a header was received.

Parameters:

Name Type Description
streamId Number The streamId of the stream that has been opened.
responseCode String The response to the opening of it.
value String The value you wish to send as a notification to the native implementation of WebView.

notifyOpen(streamId, responseCode, value)


Notifies the native implementation of WebView of the code that descriptors are open.

Parameters:

Name Type Description
streamId Number The identifier of the stream that has been opened.
responseCode String The response to the opening of it.
value String The value passed to the native implementation of WebView.

notifySystemLowMemory()


Notifies the native implementation that the WebView in the application is low on memory.

on(eventType, eventListener)


Adds a listener for a given event. Multiple listeners can be registered for the same event.

Parameters:

Name Type Description
eventType String The native event to listen for. Only the following events can be specified or the method silently fails.
The event type can be one of the following strings:
  • ContentRendered
  • ContextMenuCancelEvent
  • Created
  • Destroyed
  • DocumentLoadCommitted
  • DocumentLoaded
  • DocumentLoadFinished
  • DialogRequested
  • JavaScriptCallback
  • JavaScriptResult
  • InvokeRequestEvent
  • LocationChange
  • NetworkError
  • PropertyActiveEvent
  • PropertyBackgroundColorEvent
  • PropertyCanGoBackEvent
  • PropertyCanGoForwardEvent
  • PropertyCertificateInfoEvent
  • PropertyContentRectangleEvent
  • PropertyCurrentContextEvent
  • PropertyEnableWebInspectorEvent
  • PropertyEncryptionInfoEvent
  • PropertyFaviconEvent
  • PropertyHistoryListEvent
  • PropertyHistoryPositionEvent
  • PropertyJavaScriptInterruptTimeoutEvent
  • PropertyLoadProgressEvent
  • PropertyLocationEvent
  • PropertyOriginalLocationEvent
  • PropertyScaleEvent
  • PropertyScrollPositionEvent
  • PropertySecureTypeEvent
  • PropertyStatusEvent
  • PropertyTitleEvent
  • PropertyTooltipEvent
  • PropertyVisibleEvent
  • PropertyWebInspectorPortEvent
  • PropertyViewportEvent
  • PropertyZOrderEvent
eventListener Object The function to invoke when the specified event occurs.

once(eventType, eventListener)


Adds a listener for an event that removes itself after a single occurrence of the specified event.

Parameters:

Name Type Description
eventType String The native event to listen for. Only the following events can be listened to or the method fails silently.
The event type can be one of the following strings:
  • ContentRendered
  • ContextMenuCancelEvent
  • Created
  • Destroyed
  • DocumentLoadCommitted
  • DocumentLoaded
  • DocumentLoadFinished
  • DialogRequested
  • JavaScriptCallback
  • JavaScriptResult
  • InvokeRequestEvent
  • LocationChange
  • NetworkError
  • PropertyActiveEvent
  • PropertyBackgroundColorEvent
  • PropertyCanGoBackEvent
  • PropertyCanGoForwardEvent
  • PropertyCertificateInfoEvent
  • PropertyContentRectangleEvent
  • PropertyCurrentContextEvent
  • PropertyEnableWebInspectorEvent
  • PropertyEncryptionInfoEvent
  • PropertyFaviconEvent
  • PropertyHistoryListEvent
  • PropertyHistoryPositionEvent
  • PropertyJavaScriptInterruptTimeoutEvent
  • PropertyLoadProgressEvent
  • PropertyLocationEvent
  • PropertyOriginalLocationEvent
  • PropertyScaleEvent
  • PropertyScrollPositionEvent
  • PropertySecureTypeEvent
  • PropertyStatusEvent
  • PropertyTitleEvent
  • PropertyTooltipEvent
  • PropertyVisibleEvent
  • PropertyWebInspectorPortEvent
  • PropertyViewportEvent
  • PropertyZOrderEvent
eventListener Object The function to be invoked when the event is emitted.

publishRemoteFunction(name, handler, options)


Publishes a name that maps to a specific function. This function allows other WebViews to request execution of the handler.

Parameters:

Name Type Description
name String The name of the function to be published.
handler Object The function to publish.
options Object Optional configuration object. The subparameters are "scope" and "once".

reload()


Reloads the current WebView.

remoteExec(webviewId, name, args, callbackopt)


Performs a remote function call on another WebView.

Parameters:

Name Type Attributes Description
webviewId Number The ID of the target WebView.
name String The name of the function to call.
args Array.<Object> The arguments for the target function.
callback Callback <optional>
callback that runs on completion. This parameter is ignored on synchronous calls.

removeAllKnownSSLCertificates()


Removes all of the known SSL certificates.

removeKnownSSLCertificate(url, certificateId)


Remove the specified SSL certificate based on a matching URL and a certificate ID.

Parameters:

Name Type Description
url String The URL of the website.
certificateId String The signature of the certificate.

Example

var certificate = JSON.parse(context),
certificateId = certificate.connectionInfo.certificateInfo.certificates[0].signature,
url = certificate.url;

removeOriginAccessWhitelistEntry(sourceOrigin, destination, allowSubdomainsopt)


Allows the WebView to remove previously added whitelist entries.

Parameters:

Name Type Attributes Default Description
sourceOrigin String The URI of the source where a network request is created. Use local:// for local access.
destination String The URI of the destination of a network request.
allowSubdomains Boolean <optional>
False Specifies whether access between subdomains between source and destination origins are allowed. A value of true indicates that access between subdomains between different origins is allowed.

runRemoteExecCallback(callbackId, args)


Used as the entry point of the RPC channel to run a callback with parameters.

Parameters:

Name Type Description
callbackId Number The identifier of the callback to run.
args String A list of string parameters for the callback.

setApplicationOrientation(angle)


Sets orientation of the WebView.

Parameters:

Name Type Description
angle Number The angle of the orientation.

setBackgroundColor(color)


Sets the background color of the WebView.

Parameters:

Name Type Description
color String The desired background color of the WebView as a hex value.
Deprecated: Yes
See:
  • backgroundColor

Example

webview.setBackgroundColor("0x00FFFFFF");

setExtraPluginDirectory(directory)


Sets an extra plugin directory for the WebView.

Parameters:

Name Type Description
directory String Path to the extra directory. For example: '/usr/lib/browser/plugins'

setGeometry(x, y, width, height)


Configures the dimensions and location of the WebView on the screen.

Parameters:

Name Type Description
x Number The x-position of the WebView on the screen.
y Number The y-position of the WebView on the screen.
width Number The width of the WebView on the screen (in pixels).
height Number The height of the WebView on the screen (in pixels).

setPopupWebView(popupId)


Allow popup dialogs in the WebView.

Parameters:

Name Type Description
popupId String The popup dialog's window ID.

stop(onCompleteopt)


Stops the current WebView.

Parameters:

Name Type Attributes Description
onComplete callback <optional>
The callback that's called when this function completes.

syncProxyCredential(username, password)


Synchronizes the proxy credential of the WebView.

Parameters:

Name Type Description
username String The username of the proxy credential.
password String The password of the proxy credential.

un(eventType, eventListener)


Removes a specific registered listener for a given event.

Parameters:

Name Type Description
eventType String The native event to remove. Only the following events can be removed or the method silently fails.
The event type can be one of the following strings:
  • ContentRendered
  • ContextMenuCancelEvent
  • Created
  • Destroyed
  • DocumentLoadCommitted
  • DocumentLoaded
  • DocumentLoadFinished
  • DialogRequested
  • JavaScriptCallback
  • JavaScriptResult
  • InvokeRequestEvent
  • LocationChange
  • NetworkError
  • PropertyActiveEvent
  • PropertyBackgroundColorEvent
  • PropertyCanGoBackEvent
  • PropertyCanGoForwardEvent
  • PropertyCertificateInfoEvent
  • PropertyContentRectangleEvent
  • PropertyCurrentContextEvent
  • PropertyEnableWebInspectorEvent
  • PropertyEncryptionInfoEvent
  • PropertyFaviconEvent
  • PropertyHistoryListEvent
  • PropertyHistoryPositionEvent
  • PropertyJavaScriptInterruptTimeoutEvent
  • PropertyLoadProgressEvent
  • PropertyLocationEvent
  • PropertyOriginalLocationEvent
  • PropertyScaleEvent
  • PropertyScrollPositionEvent
  • PropertySecureTypeEvent
  • PropertyStatusEvent
  • PropertyTitleEvent
  • PropertyTooltipEvent
  • PropertyVisibleEvent
  • PropertyWebInspectorPortEvent
  • PropertyViewportEvent
  • PropertyZOrderEvent
eventListener Object The function to be removed from the list of event listeners

unpublishRemoteFunction(name)


Removes a published function name.

Parameters:

Name Type Description
name String The name of the function to remove.

WebView(options)


Create the WebView with specified parameters that are passed as options. The WebView is enabled with keyboard events and to use default webevent handlers. The options that you pass specify the WebView ID, callback function name, and process ID of the WebView.
  • options.WebViewId specifies the WebView ID to use.
  • options.onCreate specifies the WebView created callback function.
  • options.processId specifies the process ID of the WebView.

Parameters:

Name Type Description
options Object The options used for the WebView.