0

我有一个 webview 元素,其中包含我从 android studio 中的外部脚本加载的 jqmath 脚本,将变量传递到脚本中的函数如下所示:

void UpdateFunc() {
    js = "<html><head>"
            + "<link rel='stylesheet' href='file:///android_asset/mathscribe/jqmath-0.4.3.css'>"
            + "<script src='file:///android_asset/mathscribe/jquery-1.4.3.min.js'></script>"
            + "<script src='file:///android_asset/mathscribe/jqmath-etc-0.4.3.min.js'></script>"
            + "</head><body>"
            + "<script>var s =   '$$" + functext + "$$';M.parseMath(s);document.write(s);</script> </body>";
    webView.loadDataWithBaseURL("", js, "text/html", "UTF-8", "");
}

我需要运行一些函数,有人建议我扩展使用 WebViewClient 并运行 OnPageFinished(),我的代码如下(在 OnCreate 下):

webView.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView view, String url) {

            code
        }
    });

问题是,在脚本完成更新 web 视图之前调用 OnPageFinished。

有什么方法可以让我在脚本完成更新 web 视图后立即运行代码?或者如何解决 OnPageFinished 的问题?另请注意,我没有在函数中传递任何变量,因为我只有一个 webview。

提前致谢。

4

1 回答 1

0

请参阅Jqmath - 页面加载后应用

基本上,在将 jqMath 文本加载到 DOM 元素中之后,您可以在 DOM 元素上调用 M.parseMath。

于 2015-11-17T20:39:17.367 回答