WebView

Enterprise Browser 1.8

Overview

This is the core container used for rendering application code. Certain behaviors of the WebView can be controlled by using this API class.

Note: On CE devices that use the IE Engine, clicking a hyperlink while holding the shift hardware key on the device does not work properly.

Enabling the API

There are two methods of enabling the WebView API:

  • Include all ebapi modules
  • Include only the required API modules

Either way, the included files will be from: /Enterprise Browser/JavaScript Files/Enterprise Browser, a directory on the computer that contains the Enterprise Browser installation.

Include all JS API modules

To include all JavaScript APIs, copy the ebapi-modules.js file to a location accessible by the app's files and include the JavaScript modules file in the app. For instance, to include the modules file in the app's index.html, copy the modules file to the same directory as the index.html and add the following line to the HEAD section of the app's index.html file:


<script type="text/javascript" charset="utf-8" src="ebapi-modules.js"></script>

This will define the EB class within the page. Note that the path for this file is relative to the current page (index.html). Any page on which the modules are required will need to have the required .js file(s) included in this fashion.

Include only the required modules

To include individual APIs, include the ebapi.js in the HTML, and then the additional required API file(s). For instance, to use the WebView API, add the following code to the HTML file(s). Again, this assumes that relevant API files have been copied to the same directory as the HTML.


<script type="text/javascript" charset="utf-8" src="ebapi.js"></script>
<script type="text/javascript" charset="utf-8" src="eb.webview.js"></script>

In the code lines above, notice that ebapi.js is included first, followed by eb.webview.js, which is the WebView API for Enterprise Browser. This coding is required on each HTML page whenever an individual API will be called from that page.

Methods

clearApplicationCache()

Used for clearing HTML5 Application Cache data in Enterprise Browser application. Note: Use WebView clearCache API for clearing cache data.

Parameters

  • callback : CallBackHandler

Returns

Synchronous Return:

  • Void

Platforms

  • Android

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • EB.WebView.clearApplicationCache()

clearCache()

Forces WebView to clear cache data in Enterprise Browser application. Note: This doesnot clear HTML5 Application Cache data.

Parameters

  • callback : CallBackHandler

Returns

Synchronous Return:

  • Void

Platforms

  • Android

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • EB.WebView.clearCache()

clearCookies()

Forces WebView to clear cookies saved in Enterprise Browser application.

Parameters

  • callback : CallBackHandler

Returns

Synchronous Return:

  • Void

Platforms

  • Android

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • EB.WebView.clearCookies()

clearHistory()

Forces WebView to clear history in Enterprise Browser application.

Parameters

  • callback : CallBackHandler

Returns

Synchronous Return:

  • Void

Platforms

  • Android

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • EB.WebView.clearHistory()

Force WebView to navigate to a URL. White page flickering during transition may happen if a controller action method doesn't return any rendered value, but instead performs a WebView.navigate(someUrl) call.

Parameters

  • url : STRING

    Navigate to this url.

  • tabIndex : INTEGER Optional Default: -1

    TabBar tab index. If no tab bar present, index is ignored. Please avoid of navigate in not opened tab - this is unsupported on Android. Refresh active WebView.

  • callback : CallBackHandler

Returns

Synchronous Return:

  • Void

Platforms

  • Android
  • Windows Mobile
  • Windows CE

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • EB.WebView.navigate(STRING url, INTEGER tabIndex)

Force WebView to navigate to the previous page using Browser back.

Parameters

  • tabIndex : INTEGER Optional Default: -1

    TabBar tab index. If no tab bar present, index is ignored. Navigate back in active WebView.

  • callback : CallBackHandler

Returns

Synchronous Return:

  • Void

Platforms

  • Android
  • Windows Mobile
  • Windows CE

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • EB.WebView.navigateBack(INTEGER tabIndex)

refresh(INTEGER tabIndex)

Force WebView to refresh the current page.

Parameters

  • tabIndex : INTEGER Optional Default: -1

    TabBar tab index. If no tab bar present, index is ignored. Refresh active WebView.

  • callback : CallBackHandler

Returns

Synchronous Return:

  • Void

Platforms

  • Android
  • Windows Mobile
  • Windows CE

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • EB.WebView.refresh(INTEGER tabIndex)

resizeWebviewLayout(INTEGER left, INTEGER top, INTEGER width, INTEGER height)

Resize the WebView layout parameters with the specified left, top, width and height values in Enterprise Browser application.

Parameters

  • left : INTEGER

    Specifies the initial horizontal position of the webView layout in pixels.

  • top : INTEGER

    Specifies the initial vertical position of the webView layout in pixels.

  • width : INTEGER

    Specifies the width of the webView layout in pixels. The maximum value should not be greater than device Width.

  • height : INTEGER

    Specifies the height of the webView layout in pixels. The maximum value should not be greater than device Height.

  • callback : CallBackHandler

Returns

Synchronous Return:

  • Void

Platforms

  • Android

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • EB.WebView.resizeWebviewLayout(INTEGER left, INTEGER top, INTEGER width, INTEGER height)

resetWebviewLayout()

Reset the WebView layout to default in Enterprise Browser application.

Parameters

  • callback : CallBackHandler

Returns

Synchronous Return:

  • Void

Platforms

  • Android

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • EB.WebView.resetWebviewLayout()

save(STRING format, STRING path, INTEGER tabIndex)

Save current page to file system.

Parameters

  • format : STRING

    Format of the saved page.

    Possible Values :

    Constant: EB.WebView.SAVE_FORMAT_JPEG
    String:jpeg
    Save as jpeg image.
  • path : STRING

    Path to the file / folder to save the page.

  • tabIndex : INTEGER Optional Default: -1

    TabBar tab index. If no tab bar present, index is ignored. If tabbar index omitted then active WebView will be saved.

  • callback : CallBackHandler

Returns

Synchronous Return:

  • Void

Platforms

  • Android

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • EB.WebView.save(STRING format, STRING path, INTEGER tabIndex)

Properties

activeTab

Type

INTEGER Read Only

Description

Return an active tab index. For change active tab use Use EB.NativeTabbar.currentTab property.

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.activeTab

Platforms

  • Android
  • Windows Mobile
  • Windows CE

blockNetworkImage

Type

BOOLEAN

Description

Controls whether the WebView loads image resources from the network. Note that disabling all network loads using blockNetworkLoads property or via BlockNetworkLoads config tag also will prevent network images from loading, even if this flag is set to false. When the value of this setting is changed from true to false, network images resources referenced by content currently displayed by the WebView are fetched automatically. Note: This property overrides the value set using BlockNetworkImage configuration tag.

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.blockNetworkImage

Platforms

  • Android

blockNetworkLoads

Type

BOOLEAN

Description

Controls whether the WebView loads resources from the network. Use blockNetworkImage property or BlockNetworkImage config tag to only avoid loading image resources. If the value of this setting is changed from true to false, network resources referenced by content currently displayed by the WebView are not fetched until reloading of page is not done. Note: This property overrides the value which was set using BlockNetworkLoads configuration tag.

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.blockNetworkLoads

Platforms

  • Android

cacheSize

Type

INTEGER Read Only

Description

The browser cache size, in whole MBs. Defined in the Navigation\Cache parameter of the config.xml file.

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.cacheSize

Platforms

  • Windows Mobile (WebKit)

contentHeight

Type

INTEGER Read Only

Description

Gets the height of the HTML content.

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.contentHeight

Platforms

  • Android

enableZoom

Type

BOOLEAN Read Only

Description

Enable WebView zoom. Use 'EnableZoom' parameter in the config.xml file to configure this value.

Params

Default: true

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.enableZoom

Platforms

  • Android

fontFamily

Type

STRING Read Only

Description

Specifies the default font to use when rendering text in web pages. The specified font should be a TrueType font present on the device. On Windows, the default font has been set to 'Tahoma' as this is present on all Zebra devices running Windows Mobile/CE. Note that Tahoma has no italic or oblique variants. On the Enterprise Tablet, the default is Droid Sans Fallback. The font specified must be stored in \Windows for Windows Mobile/CE devices or /system/fonts folder for Enterprise Tablet. Defined in the HTMLStyles\FontFamily parameter of the config.xml file.

Access

  • Class: This property can be accessed only via the API class object.
    • EB.WebView.fontFamily

Platforms

  • Windows Mobile (WebKit)

framework

Type

STRING Read Only

Description

Same as System.webViewFramework.

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.framework

Platforms

  • Android
  • Windows Mobile
  • Windows CE

fullScreen

Type

BOOLEAN

Description

Use full screen mode.

Params

Default: false

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.fullScreen

Platforms

  • Android
  • Windows Mobile
  • Windows CE

Type

INTEGER

Description

Number of milliseconds (max. = 45000) before the browser times out and navigates to the page specified in the badlink setting. Can be defined using the Navigation\NavTimeout parameter of the config.xml file. If it is determined that the destination is unreachable regardless of wait time, the badlink may be loaded before NAVTIMEOUT. This is the time taken to establish communication with the server, not the time taken to fully load the page. Note that the navigation timeout will not be invoked when navigating to the start page. The best practice is to store the first page locally to avoid connectivity issues at start up, and then redirect to an online page if desired.

Params

Default: 45000

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.navigationTimeout

Platforms

  • Windows Mobile (WebKit)

scrollTechnique

Type

STRING Read Only

Description

Specifies the technique used to scroll about the page. Defined in the Scrolling\ScrollTechnique paramter of the config.xml file.

Params

Default: FingerScroll

Values

Possible Values (STRING):

  • Constant: EB.WebView.SCROLL_NONE - String: (None). No scrollbars will be displayed and the page will not respond to finger swipes.
  • Constant: EB.WebView.SCROLL_SCROLLBARS - String: "Scrollbars" When the size of the page is larger than the screen, scrollbars will be presented for scrolling the page.
  • Constant: EB.WebView.SCROLL_FINGER - String: "FingerScroll" Scrolling is possible using finger swiping.

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.scrollTechnique

Platforms

  • Windows Mobile (WebKit)

textZoomLevel

Type

INTEGER

Description

Sets the font size to be displayed on the page, set to 0 for the smallest font and 4 for the largest font.

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.textZoomLevel

Platforms

  • Android
  • Windows Mobile (WebKit)

userAgent

Type

STRING Read Only

Description

Defined in in the Navigation\UserAgent parameter of the config,.xml file. When visiting a web server, the WebKit browser reports itself as the specified user agent. Use the following substitution variables:

  • %p - platform name ("Windows CE " + version number)
  • %w - WebKit version number
  • %e - WebKit version number

Use the UserAgent setting to spoof the device to the server (i.e. to view content designed for the desktop on a mobile screen).

From RhoElements 2.1 onward, the default value was changed to work out of the box with a greater number of server configurations. Prior to RhoElements 2.1, the default user agent was "Mozilla/5.0 (%p) AppleWebKit/%w (KHTML, like Gecko) WebKit/%e Safari/%w"

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.userAgent

Platforms

  • Windows Mobile (WebKit)

viewportEnabled

Type

BOOLEAN Read Only

Description

Get whether viewport meta tag processing is enabled or disabled in the Navigation\ViewportEnabled parameter of the config.xml file.

Params

Default: true

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.viewportEnabled

Platforms

  • Windows Mobile (WebKit)

viewportWidth

Type

INTEGER Read Only

Description

Default viewport width to use for pages that do not have a viewport meta tag (uses 1:1 scaling if not specified). Defined in the Navigation\ViewportWidth parameter of the config.xml file.

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.viewportWidth

Platforms

  • Windows Mobile (WebKit)

zoomPage

Type

FLOAT

Description

Sets the zoom factor of the page. Factor 1.0 is no zoom, values less than 1.0 are zoomed out and values greater than 1.0 are zoomed in.It is recommended to not to use the zoom value less than 1.0 because the page doesn't look in readable format.In Android new Zoom value takes effect on current page, Previous page has to be revisited for the new zoom values to take effect

Access

  • Class: This property can only be accessed via the API class object.
    • EB.WebView.zoomPage

Platforms

  • Android
  • Windows Mobile (WebKit)