Android Question Webview Javascript Android 11 problem

anglia

Member
Licensed User
Longtime User
I have an HTML page in a Webview that has Javascript. The page has a button that calls a Javascript function to populate some text areas on the web page.

I would like to automatically populate the fields after the page is loaded so the user doesn’t need to do anything. I’ve include: <body onLoad="populate"; > to call the ‘populate’ Javascript function to replace pressing the button. This works okay on earlier Android versions but not on Android 11.

I wondered if using Webviewextras2 might help. I can’t see how to use Webviewextras2 to achieve this. Any help would be greatly appreciated.
 

drgottjr

Expert
Licensed User
Longtime User
either version of webviewextras might help (they both allow for
javascript injection).
what you really need to debug webview is to add a chromeclient.
if there is an error, you'll see it in your log. webviewextras offers
a chromeclient (i presume version2 also provides it)

post the code for the populate() function. i'm a little confused;
if you don't want the user to do anything, why provide a button in
the first place? in any case, let's see how you implemented the
click(). if i invent my own implementation to see what happens
on android 11, the result may not be the same as for your way.
 
Upvote 0

FrostCodes

Active Member
Licensed User
I have an HTML page in a Webview that has Javascript. The page has a button that calls a Javascript function to populate some text areas on the web page.

I would like to automatically populate the fields after the page is loaded so the user doesn’t need to do anything. I’ve include: <body onLoad="populate"; > to call the ‘populate’ Javascript function to replace pressing the button. This works okay on earlier Android versions but not on Android 11.

I wondered if using Webviewextras2 might help. I can’t see how to use Webviewextras2 to achieve this. Any help would be greatly appreciated.
Did you use webviewextras and turn on JS permission on it?
 
Upvote 0

anglia

Member
Licensed User
Longtime User
Many thanks to both of you for your advice.

I should have made things a bit clearer. The HTML web page was put together for use on a Windows PC a few years ago and required the user to clck the ‘populate’ button after he/she had manually created a text file.

The text data file is now automatically created and read into the web page in an HTML <textarea> tag and now needs no action by the user. I’m trying to convert the page for use in an Android app.

The Javascript was in an external Javascript (js) file linked to the web page. It must have been a mistake on my part as when I include the Javascript inside <script> tags in the HTML file (no external file), the app displays the web page as I want . I don’t know why this didn’t work on Android 11 with the external js file. I’ve now just got to get rid of the ‘populate’ button.

I didn’t use webviewextras , but I will have a good look at using it as it looks very useful.

Thanks again.
 
Upvote 0
Top