开发者

Android javascript injection, how would I call this function $(document).ready(function(){...})

开发者 https://www.devze.com 2023-03-25 03:43 出处:网络
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 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:

  1. load the url into a string
  2. inject the javascript into the string
  3. use loaddata to load the html into the webview
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号