WebViewer Component


Properties

currentPageTitle
  Returns the title of the page currently being viewed
Data type: string
Designer Writable false
Code Writeable false
Code Readable true let variable = webviewerName.currentPageTitle

currentUrl
  Returns the URL currently being viewed. This could be different from the HomeUrl if new pages were visited by following links.
Data type: string
Designer Writable false
Code Writeable false
Code Readable true let variable = webviewerName.currentUrl

followLinks
  Determines whether to follow links when they are tapped in the WebViewer. If you follow links, you can use GoBack and GoForward to navigate the browser history.
Data type: boolean
Designer Writable true <webviewer name="webviewerName" followLinks="true">
Code Writeable true webviewerName.followLinks = true
Code Readable true let variable = webviewerName.followLinks

height
  Specifies the WebViewer's vertical height, measured in pixels.
Data type: number
Designer Writable false
Code Writeable true webviewerName.height = 200
Code Readable true let variable = webviewerName.height

heightPercent
  Specifies the WebViewer's vertical height as a percentage of the Screen's Height.
Data type: number
Designer Writable false
Code Writeable true webviewerName.heightPercent = 50
Code Readable false

homeUrl
  Specifies the URL of the page the WebViewer should initially open to. Setting this will load the page.
Data type: string
Designer Writable true <webviewer name="webviewerName" homeUrl="Test homeUrl">
Code Writeable true webviewerName.homeUrl = "Test homeUrl"
Code Readable true let variable = webviewerName.homeUrl

ignoreSslErrors
  Determine whether or not to ignore SSL errors. Set to true to ignore errors. Use this to accept self signed certificates from websites.
Data type: boolean
Designer Writable true <webviewer name="webviewerName" ignoreSslErrors="true">
Code Writeable true webviewerName.ignoreSslErrors = true
Code Readable true let variable = webviewerName.ignoreSslErrors

promptForPermission
  Determine if the user should be prompted for permission to use the geolocation API while in the WebViewer. If true, prompt the user of the WebViewer to give permission to access the geolocation API. If false, assume permission is granted.
Data type: boolean
Designer Writable true <webviewer name="webviewerName" promptForPermission="true">
Code Writeable true webviewerName.promptForPermission = true
Code Readable true let variable = webviewerName.promptForPermission

usesLocation
  Specifies whether or not this WebViewer can access the JavaScript geolocation API.
Data type: boolean
Designer Writable true <webviewer name="webviewerName" usesLocation="true">
Code Writeable false
Code Readable false

visible
  Specifies whether the WebViewer should be visible on the screen. Value is true if the WebViewer is showing and false if hidden.
Data type: boolean
Designer Writable true <webviewer name="webviewerName" visible="true">
Code Writeable true webviewerName.visible = true
Code Readable true let variable = webviewerName.visible

webViewString
  Gets the WebView's String, which is viewable through Javascript in the WebView as the window.AppInventor object.
Data type: string
Designer Writable false
Code Writeable true webviewerName.webViewString = "Test webViewString"
Code Readable true let variable = webviewerName.webViewString

width
  Specifies the horizontal width of the WebViewer, measured in pixels.
Data type: number
Designer Writable false
Code Writeable true webviewerName.width = 523
Code Readable true let variable = webviewerName.width

widthPercent
  Specifies the horizontal width of the WebViewer as a percentage of the Screen's Width.
Data type: number
Designer Writable false
Code Writeable true webviewerName.widthPercent = 26
Code Readable false

class
  The styling class of the the component
Data type: string
Designer Writable true <webviewer name="webviewerName" class="Test class">
Code Writeable false
Code Readable false

id
  The styling id of the the component
Data type: string
Designer Writable true <webviewer name="webviewerName" id="Test id">
Code Writeable false
Code Readable false

name
  The name of the component that will be used to refer to it in code.
Data type: string
Designer Writable true <webviewer name="webviewerName" name="testComponent">
Code Writeable false
Code Readable false

Methods

Method name Description Parameters
canGoBack Returns true if the WebViewer can go back in the history list.
webviewerName.canGoBack()
canGoForward Returns true if the WebViewer can go forward in the history list.
webviewerName.canGoForward()
clearCaches Clear the internal webview cache, both ram and disk. This is useful when using the WebViewer to poll a page that may not be sending appropriate cache control headers.
webviewerName.clearCaches()
clearCookies Clear the webview's cookies. This is useful if you want to sign the user out of a website that uses them to store logins.
webviewerName.clearCookies()
clearLocations Clear Stored Location permissions. When the geolocation API is used in the WebViewer, the end user is prompted on a per URL basis for whether or not permission should be granted to access their location. This function clears this information for all locations. As the permissions interface is not available on phones older then Eclair, this function is a no-op on older phones.
webviewerName.clearLocations()
goBack Go back to the previous page in the history list. Does nothing if there is no previous page.
webviewerName.goBack()
goForward Go forward to the next page in the history list. Does nothing if there is no next page.
webviewerName.goForward()
goHome Loads the page from the home URL. This happens automatically when home URL is changed.
webviewerName.goHome()
goToUrl Load the page at the given URL.
webviewerName.goToUrl(url)
webviewerName.goToUrl("http://www.google.com")
url string
reload Reload the current page.
webviewerName.reload()
runJavaScript Run JavaScript in the current page.
webviewerName.runJavaScript(js)
webviewerName.runJavaScript("alert('hello');")
js string
stopLoading Stop loading a page.
webviewerName.stopLoading()
addEventListener Method used to create event listeners.
See Events below for samples.
eventName string
eventCallbackFunction callback

Events

Event name Description Parameters
beforePageLoad When a page is about to load this event is run.
webviewerName.addEventListener(
    "beforePageLoad",
    function (url) {
        //Your code here
    }
)
url string
errorOccurred When an error occurs this event is run.
webviewerName.addEventListener(
    "errorOccurred",
    function (errorCode, description, failingUrl) {
        //Your code here
    }
)
errorCode number
description string
failingUrl string
pageLoaded When a page is finished loading this event is run.
webviewerName.addEventListener(
    "pageLoaded",
    function (url) {
        //Your code here
    }
)
url string
webViewStringChange Event that runs when the AppInventor.setWebViewString method is called from JavaScript. The new WebViewString is given by the value parameter.
webviewerName.addEventListener(
    "webViewStringChange",
    function (value) {
        //Your code here
    }
)
value string