开发者

Javascript not working in loadDataWithBaseURL Android

开发者 https://www.devze.com 2023-03-15 15:34 出处:网络
I am trying to display a webpage using webView. I use loadDataWithBaseUrl to display the webpage. webView = (WebView) findViewById(R.id.webview);

I am trying to display a webpage using webView. I use loadDataWithBaseUrl to display the webpage.

webView = (WebView) findViewById(R.id.webview);
WebSettings settings=webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
    webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
    {
开发者_Go百科        (activity).setTitle("Loading...");
        (activity).setProgress(progress * 100);

        if(progress == 100)
            activity.setTitle(R.string.app_name);
    }
    });
  webView.setWebViewClient(new WebViewClient() {
  @Override
  public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
   {

   }
  });
    String s= "file://"+f.getAbsolutePath()+"/";
    webView.loadDataWithBaseURL(BASE_URL,HTMLData, "text/html", "utf-8","");

The problem I am facing is that the javascript on the page which should have been called on onLoad is not being run. The browser displays the webpage correctly. Also, the loadUrl method gives the correct results. Please suggest a possible solution. Edit: I got it sorted out. The javascript file had an error. Please ignore.

0

精彩评论

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