0

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");
4

2 回答 2

0

我终于解决了这个问题。htmlData 包含意外字符\n等等。我通过删除它们替换了我的字符串,现在它可以工作了\u0000<!--谢谢大家。

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 -->", "");
于 2016-06-25T13:16:17.243 回答
0

看起来你的表格有问题。操作无法重定向到外部站点。尝试手动从表单中获取所有值并使用 Ajax 之类的东西来发送发布请求。

于 2016-06-24T08:01:43.583 回答