Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Javascript in WebView when using LoadData

I am very new to Android Dev and I am developing what I thought would be a simple app. I have some HTML code that is stored is the raw resources folder - the code includes some Javascript. When I run the code in Google Chrome it runs fine - however when I load it into the webview using the loadData function it doesn't run the Javascript.

I have enabled javascript with:

mWebView.getSettings().setJavaScriptEnabled(true);

I need to be able to run this Javascript within the browser - any help?


1 Answers

Try this:

webView.loadDataWithBaseURL("blarg://ignored", getData(), "text/html", "utf-8", "");

like image 83
Cobaia Avatar answered Dec 06 '25 07:12

Cobaia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!