My HTML file has the following structure:
<html>
<head>
This is a test
<script>
function testingConsole() {
console.log("Reached end of Body");
}
</script>
</head>
<body>
<script type="text/javascript">testingConsole();</script>
</body>
</html>
Here's how my code looks like:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.chart);
webView = (WebView) findViewById(R.id.wvChart);
webView.loadUrl("file:///android_asset/Chart/chart.html");
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient());
webView.loadUrl("javascript:testingConsole();");
}
While the HTML file loads correctly and displays "This is a test" in the WebView, the script `testingConsole();` executes on its own when called from the HTML file. However, when I try to call it from my code, I encounter an error stating "Uncaught ReferenceError: testingConsole is not defined at null:1"