title: Call Javascript function in android webview (Uncaught ReferenceError)
body: <p>I am trying to call a javascript function inside a webview. And I keep getting the following error.
  [INFO:CONSOLE(1)] "Uncaught ReferenceError: onOTP is not defined", source:  (1)</p>
  
  <p>Please you ask, this function is only getting called inside the onPageFinished() method of the webview client. I am successfully able to call an Android function from the html but not the other way around.</p>
  
  <p>Any help?</p>
  
  <p>This is my javascript method:</p>
  
  <pre><code>function onOTP(otp){
     console.dir("Otp Triggered " + otp);
  }
  </code></pre>
  
  <p>This javascript code is inside a separate js file. I thought that might be the issue and added the same code to the html page with a script tag and still the same issue.</p>
  
  <p>And I am calling this inside:</p>
  
  <pre><code>@Override
  public void onPageFinished(WebView view, String url) {
      super.onPageFinished(view, url);
      mWebView.loadUrl("javascript:onOTP(465601)");
  }
  </code></pre>
  
  <p>Can someone please let me know what I am doing wrong in this?</p>
  
  <p>Thanks in advance for your help!</p>