How can I make JavaScript and images on my remote HTML page be loaded from assets folder (or just any local resource)?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Answer:
1. You MUST load the HTML into string:
2. Load WebView with base URL:
In this particular case you should have all .js files you want to use on the page to reside somewhere under “assets” folder of project. For example:
3. In your remote html page you have to load .js and .css files that reside in your application like:
the same applies to all other local resources like images, etc. their path has to start with
A WebView would first load the raw HTML you have provided as string, then pick .js, .css and other local resourses and then would load remote content.