I am working on some javascript injection into m android webview. I am just not completely sure of the syntax it is looking for
I want to call this function in my html page:
$(document).ready(function({...})
I have a webview and javascript interface setup in my app. I also have 开发者_开发技巧javascript enabled
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl("file:///android_asset/mydocument.html");
myWebView.addJavascriptInterface(new myJavaScriptInterface(), "jsintector");
myWebView.loadUrl("javascript:ready()");
the javascript:ready()
is supposed to be the part in the android that calls the correct function in the html page. What is the proper syntax to access this function? $(document).ready(function({...})
(edit: the javascript is already in the html, I just want to force it to run from the android side)
Try to search before...
Anyway, the simplest way to do this is to do the following:
load the url into a string
inject the javascript into the string
- use loaddata to load the html into the webview
精彩评论