我想将javascript代码嵌入到原始的facebook页面中。但是我收到了错误
“Uncaught TypeError:无法设置null”属性'value'
请帮助我。这是我的代码。
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView=(WebView)findViewById(R.id.wv);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
String email="qwerty@xyz.com";
String password="1234";
String javaScript="javascript:(function(){ document.getElementById('email').value='"+email+
"';document.getElementById('pass').value='"+password+
"';document.getElementById('u_0_a').click();})()";
view.loadUrl(javaScript);
}
});
webView.loadUrl("http://www.facebook.com");
}
}