2

I am using simple webview.Where i have given link to login page of my web application. The webview work fine until i try custom webviewClient. By adding webviewClient it stops processing of javascript.I am able to see only html part.

 webView = (WebView) findViewById(R.id.webView1);
 webView.setWebViewClient(new MyBrowser());
 WebSettings webSettings = webView.getSettings();
 webSettings.setJavaScriptEnabled(true);
 webView.loadUrl("my web application login page with jscript"); 


private class MyBrowser extends WebViewClient {
   @Override
   public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
   }
}

I am able to login successfully.There is javascript in login page,so i think it works.But after logging in it redirects to home page where onpage load javascript will append some data to html table.The data which is appended by jscript is visible in other browser,but webview not showing that data.

1 Answer 1

2

Try the below that enables javascript

  public class WebViewDemo extends Activity {
   private static final String URL_TO_LOAD = "http://google.com";
   private static final String LOCAL_RESOURCE = "file:///android_asset/html/HelloWorld.html";
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.browser_demo);
      WebView view= (WebView) findViewById(R.id.browser1);
      loadResource(view, LOCAL_RESOURCE);
   }
   private void loadResource(WebView view, String resource) {      wv.loadUrl(resource);
      view.getSettings().setJavaScriptEnabled(true);
      view.setWebChromeClient(new CustomChromeclient());
      view.setWebViewClient(new CustomWebViewclient(this));
      view.addJavascriptInterface(new JavaScriptInterface(view), "JSI");
   }  //
Sign up to request clarification or add additional context in comments.

4 Comments

yes but app asking to choose browser to compete action.Also it shows address bar.I dont want to show address bar.I need to add custom webviewClient
here wv means view????Also i am getting cannot resolve symbol error to CustomChromeclient
dear utility,I changed target url to my another web application.In this case the javascript is loading correctly.So is there any possibilities that there is some problem in my web application.
Thank you for help.The error is in web application.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.