Module: siteKiosk.ui.views.web

A module representing a web view. The web view itself inherits most of its methods from View. It also adds some browser related functions. The most important ones are:
  • back - goes back in browser history
  • getUrl - get the current url
  • guessUrl - guess url based on user input
  • navigate - navigate to another url
  • reload - reload the current page

There are also several functions to restrict the browing area. This module also offers some web browser related events that you can attach a listener to, the most important being:
  • onPageStarted - register a callback which is triggered when the page loading starts
  • onPageProgress - register a callback which is triggered when the page loading progress changes
  • onPageFinished - register a callback which is triggered when the page has completed loading
  • onError - register a callback which is triggered when the page loading fails


For an example of the web view please have a look at the WebViewApp sample from the SiteKiosk Android samples.

new siteKiosk.ui.views.web(params)

Creates a web view.
Parameters:
Name Type Description
params * The web views params
Properties
Name Type Argument Default Description
width number <optional>
100 The view's width
height number <optional>
100 The view's height
left number <optional>
0 The view's left anchor
top number <optional>
0 The view's top anchor
useRelative boolean <optional>
true
clipRect * <optional>
undefined The view's clip rect
zIndex number <optional>
0 The view's z-index
rightMargin number <optional>
0 The view's right margin
bottomMargin number <optional>
0 The view's bottom margin
visibility string <optional>
"visible" The view's visibility
privateBrowsing boolean <optional>
false Whether this web view is in private browsing mode
engine string <optional>
'' An alternative browser engine to be used (e.g. 'crosswalk')
isClosable string <optional>
true When set to false this web view will not be closable

Members

<readonly> isView :boolean

Identifies a view.
Type:
  • boolean
Inherited From:

Methods

activate()

Activates the view
Inherited From:

allowLayoutUpdates()

Enables updating the layout, when a property changes.
Inherited From:

back()

Navigates one page back in the history, if possible.

canGoBack() → {boolean}

Returns whether the history contains any previous pages.
Returns:
Whether the history contains any previous pages
Type
boolean

canGoForward() → {boolean}

Returns whether the history contains any nexw pages.
Returns:
Whether the history contains any next pages
Type
boolean

center()

Centers the view in the middle of the screen.
Inherited From:

clearHistory()

Clears the history (affects back and forward actions).

close()

Closes the web view.

disableInteraction()

Disables interaction: The webview will no longer receive any touch events or display input dialogs.

enableInteraction()

Enables interaction: The webview willreceive touch events and display input dialogs.

focus()

Focus the views
Inherited From:

forward()

Navigates one page forward in the history, if possible.

getAllowContextMenu() → {boolean}

Gets the whether the context menu display is allowed.
Returns:
True when context menu display is allowed.
Type
boolean

getAllowPrinting() → {boolean}

Gets whether this view can use print commands.
Returns:
Whether printing is allowed
Type
boolean

getBuiltInZoomControls() → {boolean}

Returns whether zoom controls are being displayed.
Returns:
Whether zoom controls are being displayed
Type
boolean

getCanMaximize() → {boolean}

Gets whether the view can be maximized
Inherited From:
Returns:
The state.
Type
boolean

getCanMinimize() → {boolean}

Gets whether the view can be minimized
Inherited From:
Returns:
The state.
Type
boolean

getCertificateWhitelist() → {*}

Gets the certificate whitelist, to white list pages, which will no longer trigger certificate warnings.
Returns:
A list of pages, which should not show certificate warnings
Type
*

getClipRect() → {*}

Gets the view's clip rect.
Inherited From:
Returns:
The view's clip rect
Type
*

getContentFilterCategories() → {Array.<string>}

Gets the categories the content filter should block.
Returns:
A set of content filter categories
Type
Array.<string>

getContentFilterMechanisms() → {Array.<string>}

Gets the mechanisms, used by the content filter. Can contain any of the following values: 'keywords', 'domains'.
Returns:
A set currently active content filter mechanisms
Type
Array.<string>

getFilterContent() → {boolean}

Gets whether this view should filter requests.
Returns:
Whether request filtering is activated
Type
boolean

getFilterExternalResources() → {boolean}

Gets whether external resources like iframes or images are being filtered.
Returns:
Whether external resources are being filtered
Type
boolean

getHeight() → {number}

Gets the view's height.
Inherited From:
Returns:
The view's height
Type
number

getHideWhenClose() → {boolean}

Gets whether the view is will hide when the user tries to close it.
Inherited From:
Returns:
The state.
Type
boolean

getIsBrowsable() → {boolean}

Gets the whether the web view control will be used to browse the internet.
Returns:
True when the control can be used to browse
Type
boolean

getIsCloseable() → {boolean}

Gets whether the view is closeable,
Inherited From:
Returns:
The closeability.
Type
boolean

getLeft() → {number}

Returns the left anchor.
Inherited From:
Returns:
The left ancor
Type
number

getLogNavigation() → {boolean}

Gets whether this view should log navigations.
Returns:
Whether logging is allowed
Type
boolean

getName() → {string}

Gets the view's name.
Inherited From:
Returns:
The view's name
Type
string

getOpacity() → {number}

Gets the view's opacity.
Inherited From:
Returns:
The view's opacity
Type
number

getPageFavIcons() → {Array.<string>}

Gets the fav icons available from the current main page
Returns:
The page fav icons
Type
Array.<string>

getPageTitle() → {string}

Gets the title of the current main page
Returns:
The page title
Type
string

getParent() → {number}

Gets the view's parent.
Inherited From:
Returns:
value The parent's view id
Type
number

getPopupHandlingMode() → {number}

Gets the current popup handling mode.
Returns:
The popup handling mode
Type
number

getRelativeClipRect() → {*}

Gets the view's relative clip rect.
Inherited From:
Returns:
The view's relative clip rect
Type
*

getRelativeLeft() → {number}

Gets the relative left anchor.
Inherited From:
Returns:
The relative left anchor
Type
number

getRelativeTop() → {number}

Gets the relative top anchor.
Inherited From:
Returns:
The relative top anchor
Type
number

getRoot() → {View}

Gets the view's root.
Inherited From:
Returns:
value The root's view
Type
View

getScriptFilter() → {*}

Gets the script filter list currently used to restrict page script access.
Returns:
A list of patters to match against
Type
*

getShowBorder() → {boolean}

Gets the whether the web view control has visible borders.
Returns:
True when the control has visible borders.
Type
boolean

getShowInTaskbar() → {boolean}

Gets wether the window should be displayeed in the taskbar
Returns:
Should this window be displayed in the taskbar
Type
boolean

getTitle() → {string}

Getsthe title of this view.
Inherited From:
Returns:
The title.
Type
string

getTop() → {number}

Returns the top anchor.
Inherited From:
Returns:
the top anchor
Type
number

getTopMost() → {boolean}

Gets if the view is top most.
Inherited From:
Returns:
Is the view top most.
Type
boolean

getUrl() → {string}

Gets the current URL.
Returns:
The URL of the currently visible page
Type
string

getUrlFilter() → {*}

Gets the URL filter list currently used to restrict page access.
Returns:
A list of patters to match against
Type
*

getUserAgent() → {string}

Gets the User-Agent HTTP header.
Returns:
The User-Agent HTTP header
Type
string

getUserAgentString() → {string}

Gets the user-agent string.
Returns:
The User-Agent HTTP header
Type
string

getUseWideViewPort() → {boolean}

Returns whether the device emulates a desktop-like view-port.
Returns:
Whether the device emulates a desktop-like view-port
Type
boolean

getVisibility() → {string}

Gets the view's visibility.
Inherited From:
Returns:
The view's visibility
Type
string

getWidth() → {number}

Gets the view's width.
Inherited From:
Returns:
The view's width
Type
number

getZIndex() → {number}

Gets the view's z-index.
Inherited From:
Returns:
The view's z-index
Type
number

getZoom() → {number}

Gets the current zoom level.
Returns:
The zoom level
Type
number

guessUrl(url) → {string}

Tries to guess the url from any user input.
Parameters:
Name Type Description
url string User input
Returns:
The guessed URL.
Type
string

invalidate()

Forces a redraw.
Inherited From:

isUrlAccessAllowed(url, log) → {boolean}

Gets whether a URL is allowed or not (defined by the URL filter).
Parameters:
Name Type Description
url string The URL to check
log boolean Whether this attempt should be logged, if it fails
Returns:
Whether the provided url is allowed
Type
boolean
Tries to navigate from any user input
Parameters:
Name Type Description
url string User input
log boolean Navigation Should this navigation be logged
Tries to render the specified HTML code
Parameters:
Name Type Description
html string HTML code to display

onActivated(callback) → {siteKiosk.ui.view~eventSubscription}

Registers a callback, which will be triggered when a view is activated
Parameters:
Name Type Description
callback siteKiosk.ui.view~activatedCallback The callback, which will be triggered when a view is activated
Inherited From:
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.view~eventSubscription

onClosed(callback) → {siteKiosk.ui.view~eventSubscription}

Registers a callback, which will be triggered when a view is closed
Parameters:
Name Type Description
callback siteKiosk.ui.view~closedCallback The callback, which will be triggered when a view is closed
Inherited From:
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.view~eventSubscription

onDeactivated(callback) → {siteKiosk.ui.view~eventSubscription}

Registers a callback, which will be triggered when a view is deactivated
Parameters:
Name Type Description
callback siteKiosk.ui.view~deactivatedCallback The callback, which will be triggered when a view is deactivated
Inherited From:
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.view~eventSubscription

onDownloadStart(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when the web view cannot render the content, because its a download.
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~onDownloadStartCallback The callback, which will be triggered when the web view cannot render the content, because its a download
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onError(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when the page load results in an error.
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~errorCallback The callback, which will be triggered when the page load results in an error
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onGotFocus(callback) → {siteKiosk.ui.view~eventSubscription}

Registers a callback, which will be triggered when a view receives the focus.
Parameters:
Name Type Description
callback siteKiosk.ui.view~gotFocusCallback The callback, which will be triggered when a view receives the focus
Inherited From:
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.view~eventSubscription

onHideCustomView(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when the custom view has been removed.
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~hideCustomViewCallback The callback, which will be triggered when the custom view has been created
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onLoadingStateChange(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when a the loading state changes (isLoading, canGo forward/back)
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~loadingStateChangeCallback The callback, which will be triggered when a state is changing
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onPageBlocked(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when a page has been blocked.
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~pageStartedCallback The callback, which will be triggered when a page has been blocked
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onPageFaviconChange(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when a the favicons of the current page have been changed
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~pageFaviconChange The callback, which will be triggered when a favicons change is happening is changing
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onPageFinished(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when a page has completed loading.
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~pageFinishedCallback The callback, which will be triggered when a page has completed loading
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onPageProgress(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when a pages progress has been changed.
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~pageProgressCallback The callback, which will be triggered when a pages progress has been changed
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onPageSecurityChanged(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when the page security level has changed.
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~pageSecurityChangedCallback The callback, which will be triggered when a page has completed loading
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onPageStarted(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when a new page is being loaded.
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~pageStartedCallback The callback, which will be triggered when a new page is being loaded
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onPageTitleChanged(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when a page title has been changed.
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~pageStartedCallback The callback, which will be triggered when a page title changes
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onPopupViewCreated(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when a popup view has been created
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~popupViewCreated The callback, which will be triggered when a popupView has been created
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onPrintRequest(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when this view wants to print something
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~printRequest The callback, which will be triggered when the view wants to print something
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

onShowCustomView(callback) → {siteKiosk.ui.views.web~eventSubscription}

Registers a callback, which will be triggered when a custom view has been created.
Parameters:
Name Type Description
callback siteKiosk.ui.views.web~showCustomViewCallback The callback, which will be triggered when a custom view has been created
Returns:
An handler to unsubscribe the event
Type
siteKiosk.ui.views.web~eventSubscription

preventLayoutUpdates()

Prevents layout changes from happening.
Inherited From:

print(jobName)

Prints the current page.
Parameters:
Name Type Description
jobName string A name for the print job

reload()

Reloads the current page.

setAllowContextMenu(value)

Sets whether the context menu display is allowed.
Parameters:
Name Type Description
value boolean The state to set.

setAllowPrinting(value)

Sets whether this view can use print commands.
Parameters:
Name Type Description
value boolean Whether printing is allowed

setBackgroundColor(colorString)

Sets the background color. Warning: Alpha values other than 0xFF may affect rendering speed.
Parameters:
Name Type Description
colorString string The color string either in hex formats #RRGGBB, #AARRGGBB or one of 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray'

setBuiltInZoomControls(builtInZoomControls)

Sets whether zoom controls should be displayed.
Parameters:
Name Type Description
builtInZoomControls boolean Whether zoom controls should be displayed

setCanMaximize(The)

Sets whether the view can be maximized
Parameters:
Name Type Description
The boolean state.
Inherited From:

setCanMinimize(The)

Sets whether the view can be minimized
Parameters:
Name Type Description
The boolean state.
Inherited From:

setCertificateWhitelist(certificateWhitelist)

Sets the certificate whitelist, to white list pages, which will no longer trigger certificate warnings.
Parameters:
Name Type Description
certificateWhitelist * A list of pages, which should not show certificate warnings

setClipRect(value)

Sets the view's clip rect.
Parameters:
Name Type Description
value * The view's clip rect
Inherited From:

setContentFilterCategories(contentFilterMechanisms)

Sets the categories the content filter should block.
Parameters:
Name Type Description
contentFilterMechanisms Array.<string> A set of content filter categories

setContentFilterMechanisms(contentFilterMechanisms)

Sets the mechanisms, used by the content filter. Can contain any of the following values: 'keywords', 'domains'.
Parameters:
Name Type Description
contentFilterMechanisms Array.<string> A selection of content filter mechanisms, which should be active

setFilterContent(value)

Sets whether this view should filter requests.
Parameters:
Name Type Description
value boolean Whether request filtering is activated

setFilterExternalResources(filterExternalResources)

Sets whether external resources like iframes or images should be filtered.
Parameters:
Name Type Description
filterExternalResources boolean Whether external resources should be filtered

setHeight(value)

Sets the view's height.
Parameters:
Name Type Description
value number The view's height
Inherited From:

setHideWhenClose(The)

Sets whether the view is will hide when the user tries to close it.
Parameters:
Name Type Description
The boolean state.
Inherited From:

setIsBrowsable(value)

Sets whether the control will be used to browse the internet.
Parameters:
Name Type Description
value boolean True to use the webview to browse

setIsCloseable(The)

Sets whether the view is closeable,
Parameters:
Name Type Description
The boolean closeability.
Inherited From:

setLeft(value)

Sets the left anchor.
Parameters:
Name Type Description
value number The left anchor
Inherited From:

setLogNavigation(value)

Sets whether this view should log navigations.
Parameters:
Name Type Description
value boolean Whether logging is allowed

setMaxSize(width, height)

Sets the view's maxSize.
Parameters:
Name Type Description
width number The view's maxWidth
height number The view's maxHeight
Inherited From:

setMinSize(width, height)

Sets the view's minSize.
Parameters:
Name Type Description
width number The view's minWidth
height number The view's minHeight
Inherited From:

setName()

Sets the view's name.
Inherited From:

setOnConfirmHandler(handler)

Sets a confirm handler. If no handler is set, the web view will show a native dialog.
Parameters:
Name Type Description
handler siteKiosk.ui.views.web~confirmHandler The handler to be invoked

setOpacity(value)

Sets the view's opacity.
Parameters:
Name Type Description
value number The view's opacity
Inherited From:

setParent(value)

Sets the view's parent.
Parameters:
Name Type Description
value number The parent's view id
Inherited From:

setPopupHandlingMode(value)

Sets the popup handling mode.
Parameters:
Name Type Description
value number The popup handling mode to set.

setPosition(left, top, isRelativePosition)

Sets the view's position.
Parameters:
Name Type Description
left number The view's left position
top number The view's top position
isRelativePosition bool Are the coordinates relative to the view´s parent.
Inherited From:

setPositionAndSize(left, top, width, height, isRelativePosition)

Sets the view's position and size.
Parameters:
Name Type Description
left number The view's left position
top number The view's top position
width number The view's width
height number The view's height
isRelativePosition bool Are the coordinates relative to the view´s parent.
Inherited From:

setRelativeClipRect(value)

Sets the view's relative clip rect.
Parameters:
Name Type Description
value * The view's relative clip rect
Inherited From:

setRelativeLeft(value)

Sets the relative left anchor.
Parameters:
Name Type Description
value number The relative left anchor
Inherited From:

setRelativeTop(value)

Sets the relative top anchor.
Parameters:
Name Type Description
value number The relative left anchor
Inherited From:

setScriptFilter(scriptFilter)

Sets the script filter list, to restrict page script access.
Parameters:
Name Type Description
scriptFilter * A list of patters to match against

setShowBorder(value)

Sets whether the control should display control borders
Parameters:
Name Type Description
value boolean True to show the borders.

setShowInTaskbar(value)

Sets whether the window should be displayed in the taskbar
Parameters:
Name Type Description
value boolean Should this window be displayed in the taskbar

setSize(width, height)

Sets the view's size.
Parameters:
Name Type Description
width number The view's width
height number The view's height
Inherited From:

setTitle(The)

Sets the view title
Parameters:
Name Type Description
The string title.
Inherited From:

setTop(value)

Sets the top anchor.
Parameters:
Name Type Description
value number The top anchor
Inherited From:

setTopMost(value)

Sets if thew view is top most.
Parameters:
Name Type Description
value boolean Should the view be top most.
Inherited From:

setUrl(value)

Sets the current URL.
Parameters:
Name Type Description
value string The URL of the page to load

setUrlFilter(urlFilter)

Sets the URL filter list, to restrict page access.
Parameters:
Name Type Description
urlFilter * A list of patters to match against

setUserAgent(userAgent)

Sets the User-Agent HTTP header.
Parameters:
Name Type Description
userAgent string The User-Agent HTTP header 1 if the web view should use a desktop user-agent string

setUserAgentString(userAgent)

Sets a user defined user-agent string.
Parameters:
Name Type Description
userAgent string The User-Agent HTTP header

setUseWideViewPort(useWideViewPort)

Sets whether the device should emulate a desktop-like view-port.
Parameters:
Name Type Description
useWideViewPort boolean Whether the device should emulate a desktop-like view-port

setVisibility(value)

Sets the view's visibility.
Parameters:
Name Type Description
value string The view's visibility
Inherited From:

setWidth(value)

Sets the view's width.
Parameters:
Name Type Description
value number The view's width
Inherited From:

setZIndex(value)

Sets the view's z-index.
Parameters:
Name Type Description
value number The view's z-index
Inherited From:

setZoom(value)

Sets the zoom level.
Parameters:
Name Type Description
value number The zoom level to set.

startNewSession()

Starts a new session.

stop()

Stops page loading.

Type Definitions

confirmHandler(url, message) → {boolean}

This handler will be invoked when a page wants to show a confirmation dialog.
Parameters:
Name Type Description
url string The url which requested the dialog
message string The message to be displayed and confirmed
Returns:
Whether the dialog has been confirmed
Type
boolean

errorCallback()

This callback will be triggered when the page load results in an error.

eventSubscription

An event subscription.
Type:
  • Object
Properties:
Name Type Description
unbind function Unsubscribes the event

hideCustomViewCallback()

This callback will be triggered when the custom view has been removed.

onDownloadStartCallback()

This callback will be triggered when the web view cannot render the content, because its a download.

pageBlockedCallback(url)

This callback will be triggered when a page is being blocked.
Parameters:
Name Type Description
url string The URL of the page which has been blocked

pageFinishedCallback(url)

This callback will be triggered when a page has completed loading.
Parameters:
Name Type Description
url string The URL of the page which is loaded

pageStartedCallback(url)

This callback will be triggered when a new page is being loaded.
Parameters:
Name Type Description
url string The URL of the page which is loading

pageStartedCallback()

This callback will be triggerd when a pages progress has been changed.

showCustomViewCallback(view)

This callback will be triggered when a custom view has been created.
Parameters:
Name Type Description
view View An object representing the custom view