0

Is it possible to inject a javascript file (located in the asset folder) to be included every time a page is loaded in android webview.

Android version: ICS 4.0.3

1 Answer 1

0

Yes, you can do this:

webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("javascript:(alert())");

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks EMODE but this does not answer my question.
You can read the JS and load it as html webView.loadDataWithBaseURL("file:///android_asset/", htmlStr, "text/html", "UTF-8", null); Answer is here: stackoverflow.com/questions/6533207/…
Do you know exactly what this means? "Read the html into a string (htmlStr)"
Loads the given data into this WebView, using baseUrl as the base URL for the content. stackoverflow.com/questions/9414312/…
Answer 2 has enough detail to get you going

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.