title: CSS from URL not working in JSoup
body: <p>I'm using jsoup to downloading and changing website and then displaying it in WebView. My problem is that css is not loading properly. I've tried deleting doctype tag like in <a href="https://github.com/AppGyver/scanner/issues/190" rel="nofollow">this issue</a> but not helped. I must add that downloaded website has good paths to stylesheet. </p>
  
  <p>Something about my code:</p>
  
  <ol>
  <li>Firstly my program download website throught jsoup</li>
  <li>Then doing some parsing and editing code</li>
  <li>Saving html to String and sending it to WebView. String has good path to css stylesheet so I don't know what cause this problem.</li>
  </ol>
  
  <p>I found that it is css problem by downloading same site on PC and launching it without css stylesheet tag.</p>
  
  <p>Here's my java class for doing above stuff:</p>
  
  <pre><code>package com.example.sqllite;
  
  import java.io.IOException;
  import java.util.List;
  
  import com.example.kontaktysqllite.R;
  
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.annotation.SuppressLint;
  import android.app.Activity;
  import android.content.Intent;
  import android.util.Log;
  import android.view.View;
  import android.webkit.WebChromeClient;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  import android.widget.Button;
  import android.widget.EditText;
  
  import org.jsoup.Jsoup;
  import org.jsoup.nodes.Document;
  import org.jsoup.nodes.DocumentType;
  import org.jsoup.nodes.Element;
  import org.jsoup.nodes.Node;
  import org.jsoup.select.Elements;
  
  /**
   * Okno danego szablonu (webview)
   * 
   * @author Alan
   * 
   */
  public class TemplateActivity extends Activity {
  
      private WebView mWebView;
      private String url;
      private StringBuffer website;
      private String websites;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.template_activity);
          // Webview
          this.url = getIntent().getExtras().getString("urlString");
          new ParseTask().execute(getIntent().getExtras().getString("urlString"));
      }
  
      private void addHtml(String html) {
          website.append(html);
      }
  
      private void getHtml() {
          String html = this.website.toString();
          websites = html;
      }
  
      private class ParseTask extends AsyncTask&lt;String, Void, Document&gt; {
          @Override
          protected Document doInBackground(String... arg0) {
              Document doc = null;
              for (String url : arg0) {
                  try {
                      doc = Jsoup.connect(url).get();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return doc;
          }
  
          @Override
          protected void onPostExecute(Document doc) {
  
              List&lt;Node&gt;nods = doc.childNodes();
              nods.get(0).remove();
  
  
  
              Elements tekst = doc.getElementsByClass("ctr-textTitle");
              for (Element div : tekst) {
                  for (Element child : div.children()) {
                      for (Element child2 : child.children()) {
                          for (Element child3 : child2.children()) {
                              for (Element child4 : child3.children()) {
                                  child4.text("heheh");
                              }
                          }
                      }
                  }
              }
  
              Elements imports = doc.select("link[href]");
              for (Element link : imports) {
                  //if (link.attr("rel") == "stylesheet") {
                      String path = link.attr("abs:href");
                      String newpath = url + path;
                      Log.i("oldpath", path);
                      Log.i("path", newpath);
                      //link.attr("abs:href", newpath);
                  //}
                 }
              String html = doc.html();
              websites = html;
  
              mWebView = (WebView) findViewById(R.id.webView1);
              mWebView.getSettings().setJavaScriptEnabled(true);
              mWebView.getSettings().setLoadWithOverviewMode(true);
              mWebView.getSettings().setUseWideViewPort(true);
              mWebView.getSettings().setBuiltInZoomControls(true);
              mWebView.getSettings().setSupportZoom(true);
              mWebView.setWebViewClient(new WebViewClient());
              // getHtml();
              Log.i("task", "" + websites);
              mWebView.loadData(websites, "text/html", "UTF-8");
          }
      }
  }
  </code></pre>
  
  <p><strong>Solution</strong>
  To load CSS i changed 117 line: </p>
  
  <pre><code>mWebView.loadData(websites, "text/html", "UTF-8");
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>mWebView.loadDataWithBaseURL(url, websites, "text/html", "UTF-8", "");
  </code></pre>
  
  <p>And it's working great not.</p>