Web Viewer¶
Category | Requires | Version |
---|---|---|
Layout > Views | API 21, Android 5.0 Lollipop | 13 |
Overview¶
Component for viewing Web pages. The Home URL can be specified in the Designer or in the Blocks Editor. The view can be set to follow links when they are tapped, and users can fill in Web forms. Warning: This is not a full browser. For example, pressing the phone's hardware Back key will exit the app, rather than move back in the browser history.
You can use the WebViewer.WebViewString property to communicate between your app and Javascript code running in the Webviewer page. In the app, you get and set WebViewString. In the WebViewer, you include Javascript that references the window.Kodular object, using the methoods getWebViewString() and setWebViewString(text).
For example, if the WebViewer opens to a page that contains the Javascript command
document.write("The answer is" + window.Kodular.getWebViewString());
and if you set WebView.WebVewString to "hello", then the web page will show
The answer is hello.
And if the Web page contains Javascript that executes the command
window.Kodular.setWebViewString("hello from Javascript"),
then the value of the WebViewString property will be
hello from Javascript.
Permissions
Events¶
After JS Evaluated¶
Get the result of the evaluated JS
Params | |
---|---|
result | Text |
Cookies Removed¶
This event return true when the cookies have been successfully removed. If the cookies was successfully cleared then the next run returns false as status, if in this time no new cookies was set.
Params | |
---|---|
success | Boolean |
On Console Message¶
Get webpage console output
Params | |
---|---|
message | Text |
line Number | Number |
source Id | Text |
On Download Start¶
Event for listening download links.
Params | |
---|---|
url | Text |
content Disposition | Text |
mime Type | Text |
content Length | Number |
Page Loaded¶
Triggers when page finished loading
Params | |
---|---|
url | Text |
Progress Changed¶
Event to detect that the loading progress has changed.
Params | |
---|---|
progress | Number |
Web View String Change¶
When the JavaScript calls AppInventor.setWebViewString this event is run.
Params | |
---|---|
value | Text |
Methods¶
Can Go Back¶
Returns: Boolean
Returns true if the WebViewer can go back in the history list.
Can Go Back Or Forward¶
Returns: Boolean
Returns true if the WebViewer can go back or forward the number of steps in the history list.
Params | |
---|---|
steps | Number |
Can Go Forward¶
Returns: Boolean
Returns true if the WebViewer can go forward in the history list.
Clear Caches¶
Clear WebView caches.
Clear Cookies¶
Start to clear the WebView cookies.
Clear Locations¶
Clear stored location permissions.
Evaluate JS¶
Evaluate JS in the context of the current page
Params | |
---|---|
script | Text |
Go Back¶
Go back to the previous page in the history list. Does nothing if there is no previous page.
Go Back Or Forward¶
Go forward or backward a number of steps away from the current page. Steps is negative if backward and positive if forward.
Params | |
---|---|
steps | Number |
Go Forward¶
Go forward to the next page in the history list. Does nothing if there is no next page.
Go Home¶
Loads the home URL page. This happens automatically when the home URL is changed.
Go To URL¶
Load the page at the given URL.
Params | |
---|---|
url | Text |
Load HTML¶
Load HTML content using Base64-encoded data URI scheme
Params | |
---|---|
html | Text |
Reload¶
Reloads the current page
Stop Loading¶
Stops the current load.
Properties¶
Current Page Title¶
Text Read - Blocks
Title of the page currently viewed
Current URL¶
Text Read - Blocks
URL of the page currently viewed. This could be different from the Home URL if new pages were visited by following links.
Desktop Mode¶
Available as Advanced Property
Boolean Default: false Read Write - Designer Blocks
Get/Set Desktop mode by altering the user agent string.
Enable JavaScript¶
Boolean Default: True Read Write - Designer Blocks
Enable/Disable JavaScript. Enabled by default
Follow Links¶
Available as Advanced Property
Boolean Default: True Read Write - Designer Blocks
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.
Height¶
Number Read Write - Blocks
Specifies the component's vertical height, measured in pixels.
Height Percent¶
Number Write - Blocks
Specifies the component's vertical height as a percentageof the height of its parent Component.
Home Url¶
Text Read Write - Designer Blocks
URL of the page the WebViewer should initially open to. Setting this will load the page.
Ignore SSL Errors¶
Available as Advanced Property
Boolean Default: False Read Write - Designer Blocks
Determine whether or not to ignore SSL errors. Set to true to ignore errors. Use this to accept self signed certificates from websites.
Load Images¶
Available as Advanced Property
Boolean Default: True Read - Designer Blocks
Whether or not to automatically load images
Prompt for Permission¶
Available as Advanced Property
Boolean Default: True Read Write - Designer Blocks
If True, then prompt the user of the WebView to give permission to access the geolocation API. If False, then assume permission is granted.
Scrollbar¶
Boolean Default: True Read Write - Designer Blocks
Whether to display a scrollbar
Use External Browser¶
Available as Advanced Property
Boolean Default: False Read Write - Designer Blocks
Open a link in the webviewer page using the external browser. If true the page will be loaded in the external browser and not in the webviewer itself.
User Agent¶
Available as Advanced Property
Text Read Write - Designer Blocks
Get User Agent
Uses Location¶
Available as Advanced Property
Boolean Default: False Write - Designer
Whether or not to give the application permission to use the Javascript geolocation API. This property is available only in the designer.
Visible¶
Boolean Default: True Read Write - Designer Blocks
Returns true iff the component is visible.
Web View String¶
Text Read Write - Blocks
Gets the WebView's String, which is viewable through Javascript in the WebView as the window.AppInventor object
Width¶
Number Read Write - Blocks
Specifies the component's horizontal width, measured in pixels.
Width Percent¶
Number Write - Blocks
Specifies the component's horizontal width as a percentageof the Width of its parent Component.
Zoom Display¶
Boolean Default: True Read - Designer Blocks
Show or Hide the zoom display.
Zoom Enabled¶
Boolean Default: True Read - Designer Blocks
Enable or Disable pinch zooming. This effects both pinch zooming and the zoom controls.
Zoom Percent¶
Number Default: 100 Read - Designer Blocks
The zoom of the page in percent %