How does the property Webviewer.WebViewString work ?
SEO Help and Tips
How does the property Webviewer & WebViewString work ?
Details: You can use WebViewString to communicate values back and forth between your App and the WebViewer. In your App, you get and set the WebViewer.WebViewString properties. In you webviewer, you open to a page that has Javascript that references the window.AppInventor object, using its getWebViewString() and setWebViewString(text) methods. Thank you Hal and Jeff for this great enhancement!
For the example, I uploaded a html page as asset into App Inventor. Alternatively of course you can use a directory on the SD card, e.g. file:///sdcard/Temp/stuff.html
There is one special thing to consider for HTML documents uploaded as assets into App Inventor: During development, you have to use the development path to the embedded HTML document.
"file:///mnt/sdcard/AppInventor/assets/webviewstring.html"
Before building the app, use the production path.
"file:///android_asset/webviewstring.html"
HTML file:
"<!doctype html>
<head>
<meta name="author" content="puravidaapps.com">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test</title>
</head>
<body>
<script>
document.write("The value from the app is<br />" + window.AppInventor.getWebViewString());
window.AppInventor.setWebViewString("hello from Javascript")
</script>
</body>
</html>"
Comments
Post a Comment
Thanks for your Comments.