的Andr​​oid的WebView:如何JavaScript的执行后页面加载 [英] Android WebView: how to load page after javascript execution

查看:137
本文介绍了的Andr​​oid的WebView:如何JavaScript的执行后页面加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关这太问题

我要删除的通知,以及在Android上的WebView显示的TeX时出现闪烁。

I want to remove the notifications as well as the flicker that occurs when displaying TeX in a WebView in android.

我试过的AsyncTask方法,以preLOAD的页面,然后选择下载吧,将数据加载到web视图之前,但我卡在一个IllegalStateException:目标主机不能为空,或参数设置。此错误是由以下code到来:

I tried the AsyncTask method, to preload the page and then "download" it, before loading the data into the WebView but I'm stuck on an IllegalStateException: Target host must not be null, or set in parameters. This error is coming from the following code:

    protected String doInBackground(String... url) {
        String r = "";
        try {
            HttpClient hc = new DefaultHttpClient();
            HttpGet get = new HttpGet(URLEncoder.encode(url[0], "UTF-8"));
            // get.setHeader("host", "http://myapp");
            HttpResponse hr = hc.execute(get);
        ...
    }

注释掉该生产线是什么,我曾试图解决这个错误,但从来没有工作过。

The line commented out is what I had tried to fix this error, but never worked.

现在我想我无法解决这个得到,因为网​​址[0] 是我加载的形式是: JavaScript的:从存储在我的资产JS文件somescript(输入)执行,也许HTTPGET需要一个Web服务器

Now I'm thinking I can't get around this because the url[0] that I'm loading is in the form: javascript:somescript(input) executed from a JS file stored in my assets, and maybe HttpGet requires a web server?

我怎样可以隐藏通知和更新的WebView然后前完成JavaScript的?

How can I hide the notifications and finish the JavaScript before updating the WebView then?

推荐答案

HTTPGET 类是一个HTTP请求,因此该URL必须以 HTTP://

The HttpGet class is for an HTTP request, so the URL must start with http://.

如果您正在使用MathJax作为TeX的观众,则指的是这个堆栈溢出问题,可以添加 messageStyle:无您MathJax配置。这种方式可以在任何环境中禁用MathJax的装载通知。

If you are using MathJax as the TeX viewer, then refering to this Stack Overflow question, you could add messageStyle: "none" to your MathJax configuration. This way can disable MathJax's loading notifications in any environments.

这篇关于的Andr​​oid的WebView:如何JavaScript的执行后页面加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆