calling javascript function from an android activity

后端 未结 7 1824
心在旅途
心在旅途 2021-01-06 01:13

I wan to call a javascript function from an android activity but it doesn\'t seem to work. I have used the android webview function webview.loadUrl(\"javascript:function()\"

7条回答
  •  清歌不尽
    2021-01-06 01:54

    It's likely your page isn't fully loaded by the time you're trying to execute the javascript. Can you try:

    webView.setWebViewClient(new WebViewClient() {
    
       public void onPageFinished(WebView view, String url) {
            view.loadUrl("javascript:change(i)");
        }
    });
    

提交回复
热议问题