2

我正在尝试填写一些字段(工作)然后单击登录按钮(不工作)我尝试过:

document.getElementById('loginButton').click();"

document.forms['form'].submit();

按钮名称和表单名称是正确的,我做错了什么?

webview.setWebViewClient(new WebViewClient() {  
             @Override  
             public void onPageFinished(WebView view, String url)  
             {  
                 webview.loadUrl("javascript:(function() { " +  
                      "document.getElementById('coCode').value = 'CompanyCode';" +
                      "document.getElementById('loginName').value = 'LoginName';" +
                      "document.getElementById('password').value = 'Password';" +
                      //"document.forms['form'].submit();" + //Doesn't Work
                      //"document.getElementById('loginButton').click();" + //Doesn't Work
                    "})()");
             }  
         });
4

1 回答 1

3

我想通了,以下对我有用:

webview.loadUrl("javascript:WebForm_DoPostBackWithOptions(
  new WebForm_PostBackOptions('loginButton', '', true, '', '', false, true))");
于 2013-03-12T04:28:41.180 回答