2

I am trying to load a local javascript file from a webview. The file "search.js" is located under the assets folder in my project. I used this line to load my webpage :

mWebView.loadDataWithBaseURL("file:///android_asset/", data, "text/html", "utf-8", null);

on my webpage, I am using this line :

<script type="text/javascript" src="search.js"></script>

to load my javascript file.

When I run the program, I just get a white page..............

I don't know what to do. Do you have any ideas ?

Thanks !!

1 Answer 1

7

Try this:

wv.loadUrl("file:///android_asset/yourfile.html");
wv.getSettings().setJavaScriptEnabled(true);
Sign up to request clarification or add additional context in comments.

1 Comment

change the order of above two statements as well :)

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.