Answer the question
In order to leave comments, you need to log in
Why is javascipt in webview not fully working?
There is a page that is loaded using the okHttp library,
after which html is parsed and the necessary data is retrieved.
The next step is to load the page in the webview.
webView.loadDataWithBaseURL(null, result, "text/html", "UTF-8", null);
@Override
public void onPageFinished(WebView view, String url) {
view.loadUrl(
"javascript:(" +
"window.onload = function ready() { " +
"var btnOpen = document.getElementsByClassName('btn btn-primary js-ask');" +
"btnOpen[0].click();" +
"var btnSend = document.getElementsByClassName('btn btn-primary pull-right');" +
"var question = document.getElementById('id_question').value=" + question + ";" +
"var name = document.getElementById('id_user_name').value='" + name + "';" +
"var email = document.getElementById('id_email').value='" + email + "';" +
"var captchaEdit = document.getElementById('id_captcha_1').value='" + captcha + "';" +
"console.log('btnSend[0]);" +
"btnSend[0].click();" +
"})()");
}
"about:blank#", source: about:blank (1)
"[object HTMLInputElement]", source: about:blank (1)
Answer the question
In order to leave comments, you need to log in
After loading data from the web (webView.loadUrl(" http://... ");) and injecting everything worked fine. For those who come across this situation: load the page immediately from the Internet without dancing with a tambourine.
Firstly, it seems that your code is not a url after all, and stuffing it into loadUrl is at least strange. Xs, not a webview guru %)
Secondly, you need to try to enable JavaScript, in my opinion, it is disabled by default:webView.getSettings().setJavaScriptEnabled(true);
Try the Scripto library . She will solve your problems
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question