In Android, how can I set the value of a edit box in WebView using Javascript

后端 未结 4 1509
醉酒成梦
醉酒成梦 2021-02-09 14:27

I understand how to set the value of a edit box in WebView, and in a browser on PC with Javascript.

It is basically first find out the ID of the edit box (text), then s

4条回答
  •  粉色の甜心
    2021-02-09 15:21

    I would imagine you are running the command before the page is loaded or it cannot resolve document itself. You should write this code as a function included in your document and then have android do:

    mWebView.loadUrl("javascript: myFunction('test')");
    

    Or better still, use @JavascriptInterface

提交回复
热议问题