0
votes

I am trying to open an html page on webview using loadData method with the string parameter which has the html + javascript code.

But the result is not what I wanted. As I understand it did not load javascript parts even though I enabled javascript.

If it is not possible with webview, is there another way to show my page on android phone which supports javascript codes? Thanks in advance.

enter image description here

This is my related code:

 WebView mWebView = (WebView) findViewById(R.id.activity_main_webview);
 WebSettings webSettings = mWebView.getSettings();
 webSettings.setJavaScriptEnabled(true);
 mWebView.loadData(htmlData, "text/html; charset=utf-8", "UTF-8");
2
Really no one has any information about this? - Hilal

2 Answers

0
votes

Looks like something wrong with your form. Action cant redirect to external site. Try to get all values from form manually and use something like Ajax to send post request.

0
votes

I have solved the problem finally. The htmlData contains unexpected characters which are \n and \u0000 and <!-- etc. I replaced my string by deleting them and now it works. Thanks for all.

htmlData = htmlData.replace("\\n", "");
htmlData = htmlData.replace("\\t", "");
htmlData = htmlData.replace("\\u0000", "");
htmlData = htmlData.replace("\\", "");
htmlData = htmlData.replace("\"\"\"", "");
htmlData = htmlData.replace("<!--function", "function");
htmlData = htmlData.replace("<!-- about:blank -->", "");