我有一个简单的javascript,我想给这些输入值,即用户名和密码。我使用webview打开网站。当webview完全加载时,用户名和密码位置根本不会改变。
网站:http://www.malaysiakini.com/login/en/form
我的javascript源代码:
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
view.loadUrl("javascript: {" +
"$('input#username').val(" + user + ");\n" +
"$('input#username').val(\"password\");\n" +
"document.querySelectorAll(\"button[type='submit']\")[0].click();}");
}
答案 0 :(得分:0)
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
view.loadUrl("javascript: {" +
"$('input#username').val('" + user + "');\n" +
"$('input#username').val(\"password\");\n" +
"document.querySelectorAll(\"button[type='submit']\")[0].click();}");
}
傻了我,我错过了单引号