Call jQuery function in Android's WebView from Java?

前端 未结 4 1040
心在旅途
心在旅途 2021-01-15 01:19

I am trying to call javascript function which is defined in html like

WebView.loadUrl(\"javascript:hoge()\");

I can call non-jQuery functio

4条回答
  •  青春惊慌失措
    2021-01-15 01:55

    What you can do is pass a query string parameter when you call the webview (eg. method=hoge).

    Then in your javascript you can check the existance of the param and run the hoge() method accordingly

    Not sure if your interested, but you can also call your android java code from javascript using the android javascript interface, see http://developer.android.com/guide/webapps/webview.html

提交回复
热议问题