1

Parts of an Android webview url have already fired by the time onLoadResource is activated. The delay is minimal but can be clearly seen...

public void onLoadResource(WebView view, String url) {
  injectScriptFile(webview, "hello.js");
  super.onLoadResource(view, url);
}

Is there a way to inject javascript into the webview before anything in the body tag renders?

Zoe
  • 27,060
  • 21
  • 118
  • 148
David
  • 13,619
  • 15
  • 45
  • 51

1 Answers1

0

if overriding the webViews shouldOverrideUrlLoading doesn't do the trick, i think the earliest way to inject javascript into your webView is by annotating an injecting method as a JavascriptInterface so it can be called from the website you are loading

Pynnie
  • 136
  • 12