Call A Javascript Function From The Activity?
How can I call a function in a HTML doc that is loaded into a webView with a button that is in my activity? ie: An ImageButton (called: bookBtn) is in the title bar of the activit
Solution 1:
There are at least two problems in the code:
1) The javascript URL doesn't invoke the loadTOC function, it just references it. What you want is:
mWebView.loadUrl("javascript:loadTOC()");
2) The loadTOC
function isn't globally visible AFAIK, so the javascript URL won't be able to access it.
You should also make sure that JavaScript is enabled as no-good-at-coding suggests.
Solution 2:
I don't see in here so I'm going to add that you ought to make sure you have
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.getSettings().setJavaScriptEnabled(true);.
in your Android code
Post a Comment for "Call A Javascript Function From The Activity?"