Issue
Might be a silly question but I don't know how to include the src URL for my javascript into the Webview?
I build a huge html tag in code, passing in variables, and then print them using flot diagrams. The javascript files reside in my asset folder, so in static html page I simply refer to them as file:///android_asset/jquery.flot.js.
But how do I do that when it's all built up by code? This doesn't seem to work
"<script language=\"javascript\" type=\"text/javascript\" src=\"file:///android_asset/jquery.flot.js\"></script>" +
Regards
Solution
First make sure your references are right, second... research if you can include a local Javascript, cause I'm not sure of that.
But why don't you try generating the Javascript code (read from the file) whitin the <script>
tag? Maybe it could be a solution.
Edited:
Have you had a look to this? It's on WebView's public void loadDataWithBaseURL (String baseUrl, String data, String mimeType, String encoding, String historyUrl)
method description:
Note for post 1.0. Due to the change in the WebKit, the access to asset files through "file:///android_asset/" for the sub resources is more restricted. If you provide null or empty string as baseUrl, you won't be able to access asset files. If the baseUrl is anything other than http(s)/ftp(s)/about/javascript as scheme, you can access asset files for sub resources.
Answered By - mdelolmo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.