0

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)

CQM
  • 42,592
  • 75
  • 224
  • 366

1 Answers1

-1

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
Sherif elKhatib
  • 45,786
  • 16
  • 89
  • 106
  • Yeah, you have to force android to load javascript sometimes even after the page has loaded, if you search you'll see this is a common problem here - frequently unanswered. The javascript is already in the html file – CQM Aug 04 '11 at 19:20