title: .click javascript function in android WebView
body: <p>I'm trying to click on a link in a page through a WebView programmatically.</p>
  
  <p>My Java function.</p>
  
  <pre><code>public class Refresh extends Activity{
  
  WebView planView;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_refresh);
  
      planView=(WebView)findViewById(R.id.webViewRefresh);
      planView.getSettings().setJavaScriptEnabled(true);
      planView.addJavascriptInterface(new MyJavaScriptInterface(this), "Call");
      planView.setWebChromeClient(new WebChromeClient());
      planView.setWebViewClient(new InsideWebViewClient());
      planView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
      planView.loadUrl(link);
      planView.setWebViewClient(new WebViewClient() {
          @Override  
          public void onPageFinished(WebView view, String url)  
          {   
              planView.loadUrl("javascript:window.document.getElementsByTagName('a')[6].click()"); //This little thing isn't working
          }
  });}
  </code></pre>
  
  <p>But there is a problem with this click() function.</p>
  
  <p>Here is the error</p>
  
  <blockquote>
    <p>TypeError: 'undefined' is not a function (evaluating "window.document.getElementsByTagName('a')[6].click()") at undefined:1</p>
  </blockquote>
  
  <p>I'm really new to Java, Android and Javascript.</p>
  
  <p>Thank you in advance to any one who may be able to give me some ideas.</p>