The Webview
is the core container used for rendering your application code. You can control certain behaviours of the webview by using this API class.
This API is part of the coreapi
extension that is included automatically.
extensions: ["coreapi"]
Be sure to review the JavaScript API Usage guide for important information about using this API in JavaScript
Be sure to review the Ruby API Usage guide for important information about using this API in Ruby
Use Rho::NativeTabbar.currentTab property: returns the current tab index.
Synchronous Return:
Method Access:
Rho.WebView.active_tab()
Rho::WebView.active_tab()
Returns the relative url (location) of the current page(without server and port); the last URL loaded to WebView from controller action.
Parameters
TabBar tab index. If no tab bar present, index is ignored. Current location of active WebView.
Synchronous Return:
Method Access:
Rho::WebView.currentLocation(INTEGER tabIndex)
Returns the actual URL in WebView. This works the same as the JavaScript window.location.href.
Parameters
TabBar tab index. If no tab bar present, index is ignored. Current url of active WebView.
Synchronous Return:
Method Access:
Rho::WebView.currentURL(INTEGER tabIndex)
Execute JavaScript on the current page from your controller.
Parameters
The call to the JavaScript method on the current page, such as "test();".
TabBar tab index. If no tab bar present, index is ignored. Execute JavaScript in active WebView.
Synchronous Return:
Method Access:
Rho::WebView.executeJavascript(STRING JavaScriptText, INTEGER tabIndex)
Use WebView.fullScreen property: Switch to/from full screen mode.
Parameters
Synchronous Return:
Method Access:
Rho.WebView.full_screen_mode(BOOLEAN enable)
Rho::WebView.full_screen_mode(BOOLEAN enable)
Force WebView to refresh the current page.
Parameters
TabBar tab index. If no tab bar present, index is ignored. Refresh active WebView.
Synchronous Return:
Method Access:
Rho.WebView.refresh(INTEGER tabIndex)
Rho::WebView.refresh(INTEGER tabIndex)
Save current page to file system.
Parameters
Format of the saved page.
Possible Values :
Path to the file/folder to save the page.
TabBar tab index. If no tab bar present, index is ignored. If tabbar index ommited then active WebView will be saved.
Synchronous Return:
Method Access:
Rho.WebView.save(STRING format, STRING path, INTEGER tabIndex)
Rho::WebView.save(STRING format, STRING path, INTEGER tabIndex)
When WebView loads the specified url (either by selecting link or from calling WebView.navigate), it will add this cookie to the HTTP request.Not implemented for Zebra Technologies' WebKit.
Parameters
Set a cookie to be used by WebView for this url.
One or more name/value pairs of the format "NAME=VALUE". Separate multiple name/value pairs with a semicolon, such as "NAME1=VALUE1; NAME2=VALUE2".
Synchronous Return:
Method Access:
Rho::WebView.setCookie(STRING url, STRING cookie)
Property Access:
Rho.WebView.activeTab
Rho::WebView.activeTab
Property Access:
Rho.WebView.cacheSize
Rho::WebView.cacheSize
Default: true
Property Access:
Rho.WebView.enableCache
Rho::WebView.enableCache
Default: true
Property Access:
Rho.WebView.enablePageLoadingIndication
Rho::WebView.enablePageLoadingIndication
Default: true
Property Access:
Rho.WebView.enableWebPlugins
Rho::WebView.enableWebPlugins
Default: true
Property Access:
Rho.WebView.enableZoom
Rho::WebView.enableZoom
Property Access:
Rho.WebView.fontFamily
Rho::WebView.fontFamily
Property Access:
Rho.WebView.framework
Rho::WebView.framework
Default: false
Property Access:
Rho.WebView.fullScreen
Rho::WebView.fullScreen
Default: FingerScroll
Possible Values (STRING):
Property Access:
Rho.WebView.scrollTechnique
Rho::WebView.scrollTechnique
Property Access:
Rho.WebView.textZoomLevel
Rho::WebView.textZoomLevel
Property Access:
Rho.WebView.userAgent
Rho::WebView.userAgent
Default: true
Property Access:
Rho.WebView.viewportEnabled
Rho::WebView.viewportEnabled
Property Access:
Rho.WebView.viewportWidth
Rho::WebView.viewportWidth
Property Access:
Rho.WebView.zoomPage
Rho::WebView.zoomPage
#call JavaScript alert on the current page Rho::WebView.executeJavascript("alert('This is Webview.executejavascript function');")
#call JQuery Mobile from a Ruby controller Rho::WebView.executeJavascript("$.mobile.changePage('#my_page');")
function greet(name) { alert("Hello, "+name); }
#call a custom JavaScript function from Ruby Rho::WebView.executeJavascript("greet('John Doe');")
# Toggle fullScreen on / off Rho::WebView.fullScreen = !Rho::WebView.fullScreen
// Fullscreen can also be invoked from JavaScript Rho.WebView.fullScreen = true; Rho.WebView.fullScreen = false;
#Force WebView to navigate to a URL. Rho::WebView.navigate(url_for(:action => :my_action))
#Navigate out of the local application and into an externally-served site Rho::WebView.navigate("http://www.example.com");
//Navigate out of the local application and into an externally-served site Rho.WebView.navigate("http://www.example.com");
#Force WebView to navigate to the previous page using Browser back. Rho::WebView.navigateBack
//Force WebView to navigate to the previous page using Browser back.
Rho.WebView.navigateBack();
# Update database or variables here # ... # Refresh the current page to show new information Rho::WebView.refresh
# Reload the page on WebView number 2 Rho::WebView.refresh(2)
// Reload the current page Rho.WebView.refresh() // Reload the page on WebView number 3 Rho.WebView.refresh(3)