title: How inject javascript before the web page loading in Android Webview?
body: <p>Really need someone to help me out.</p>
  
  <p>I am trying to inject the javascript into the web page before the page loaded in android webview.</p>
  
  <p>I searched a lot and only found solution that injecting javascript after the page is already loaded. like this:<a href="http://lexandera.com/2009/01/injecting-javascript-into-a-webview/" rel="nofollow">http://lexandera.com/2009/01/injecting-javascript-into-a-webview/</a></p>
  
  <p>Actually I need to inject something like:</p>
  
  <pre><code>document.onreadystatechange = function () {
   if (document.readyState == 'interactive') 
   {
     do something to call Android exposed JavascriptInterface
   }
  };
  </code></pre>
  
  <p>I need to inject this before the page loading because i need to listen to some event before the page is fully loaded. for example: i need to know when the page is ready to be interactive so that i can turn off the progress bar.
  (I also expose an JavascriptInterface in my Android code by <code>webview.addJavascriptInterface()</code>)</p>
  
  <p>I am wondering whether there's a way to add javascript before the page is load. And will combine my javascript into that page.</p>
  
  <p>Something like:</p>
  
  <pre><code>webview.loadUrl("javascript:some javascript");
  webview.loadUrl("www.google.com");
  </code></pre>
  
  <p>Seems not working.</p>