title: Android WebView and executing javascript
body: <p>I have a html file that looks like this</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
       This is a test
      &lt;script&gt;
      function testingConsole() {
      console.log("Reached end of Body");
      }
      &lt;/script&gt;
  
  
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;script type="text/javascript"&gt;testingConsole();&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And my code looks like this</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.chart);
  
      webView = (WebView) findViewById(R.id.wvChart);
      webView.loadUrl("file:///android_asset/Chart/chart.html");
      WebSettings webSettings = webView.getSettings();
      webSettings.setJavaScriptEnabled(true);
      webView.setWebChromeClient(new WebChromeClient());
  
      webView.loadUrl("javascript:testingConsole();");
  }
  </code></pre>
  
  <p>The html file is loading fine and the text "This is a test" is displayed in my WebView. And the script testingConsole(); is execuded by itself as it should be since html file is calling it. But when I call it from my code I get an error "Uncaught ReferenceError: testingConsole is not defined at null:1"</p>