views:

40

answers:

1

I have a JS file that has functions to search a document for substrings.

I want to access functions inside this file by passing parameters to it (the search keyword).

I know we can use .loadUrl("javascript:~~~~~) but I'm not clear on how to do it using multiple functions.

Anyone who can point me in the right direction?

Thanks!

+2  A: 

You can try this.

webview.getSettings().setJavaScriptEnabled(true);  
webview.setWebViewClient(new WebViewClient() {  
  @Override  
  public void onPageFinished(WebView view, String url){
    webview.loadUrl("javascript:(function() { " +  
    "var script=document.createElement('script');" +
    "script.type='text/javascript';script.src=" + jsFileURL + ";" +
    "script.onload=function("+queryString+"){//it can be your search function};"
    "document.getElementsByTagName('head').item(0).appendChild(script);"+  
    "})()");  
  }  
});  
webview.loadUrl("http://SOMEURL");
bhups
thanks.... I had to hack it quite a bit to suit my needs but it worked beautifully... :)
Siddharth Iyer