Android WebView Compile a Form and submit with Javascript

前端 未结 1 1714
刺人心
刺人心 2021-01-13 12:43

I\'m trying to complete this form :

http://www.lbalberti.it/whatsup.asp?codist=57247

I was able to insert value to the two textbox but the button doesn\'t wo

相关标签:
1条回答
  • 2021-01-13 13:12
     @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
    
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                view.evaluateJavascript("javascript:document.getElementById('username').value ='" + strUsername + "';javascript:document.getElementById('password').value = '" + strPassword + "';javascript:document.getElementById('loginButton').click();", null);
            } else {
                view.loadUrl("javascript:document.getElementById('username').value = '" + strUsername + "';javascript:document.getElementById('password').value = '" + strPassword + "';javascript:document.getElementById('loginButton').click();");
            }
    
    }
    
    0 讨论(0)
提交回复
热议问题