title: Android Webview HTML Loading Javascript Problem
body: <p>I've been battling this problem for over 48 hours now and I have been unable to find an answer anywhere on the net.  Here's the setup:</p>
  
  <p>My Android application is downloading content during first run (content is over 20MB) and the files are unzipped onto the user's SD card at /mnt/sdcard/{my package}/folder.  The content includes HTML files, CSS files, JS files and images.  Here's the full structure of what is written to the SD card (where / = /mnt/sdcard/{my package}/folder/):</p>
  
  <p>/content/</p>
  
  <pre><code>a.html
  b.html
  images/
    image1.jpg
  </code></pre>
  
  <p>/css/</p>
  
  <pre><code>c.css
  d.css
  </code></pre>
  
  <p>/js/</p>
  
  <pre><code>e.js
  f.js
  </code></pre>
  
  <p>Here is my code that loads the html file from the SD card:</p>
  
  <pre><code>    webView = (WebView) findViewById(R.id.pageBrowser);
      webView.getSettings().setJavaScriptEnabled(true);
      webView.addJavascriptInterface(new LinkHandlerInterface(), "Android");
      webView.setWebViewClient(new PageWebViewClient());
  
      // contentLocation + url is equal to the full path to the html file
      webView.loadUrl("file://" + contentLocation + url);
  </code></pre>
  
  <p>This code successfully loads the HTML page. No problems yet.  Each page has the following head tag:</p>
  
  <pre><code>    &lt;link rel="stylesheet" type="text/css" href="../css/screen.css" media="all" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="../css/inPractice.css" media="all" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="../css/inPracticeScheme.css" media="all" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="../css/mobile/iPad.css" media="all" /&gt;
      &lt;script type="text/javascript" src="../js/jquery-1.3.2.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="../js/inPractice-utilities.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="../js/inPractice.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="../js/mobile/inpractice.ipad.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Here is where the problem is.  My WebView renders the HTML just fine.  It even loads and applies the CSS perfectly.  However, it refuses to load and execute the Javascript.  If you remember from above, the js folder is, in fact, one leve up from the html file, so it's pointing to the correct place. </p>
  
  <p>Here's a list of what I know:</p>
  
  <ul>
  <li><p>The CSS I'm using is being applied fine, so I know the issue is not with the file location.</p></li>
  <li><p>I used this same code before, but was loading the files from my application's assets folder (file:///android_assets/...) and it worked perfectly.  Since the content is so large, I can't bundle it with my application, hence the move to the SD card.</p></li>
  <li><p>If I change the HTML files in such a way that all the Javascript methods are listed inside a script tag, it works fine. I don't have control over the HTML, so I can't apply this change permanently.  This tells me that the WebView has no problem executing the Javascript.</p></li>
  <li><p>Images load fine.</p></li>
  </ul>
  
  <p>I'm fresh out of ideas now. Does anyone have any clue why my WebView cannot load my Javascript files? Has anyone seen this before?</p>
  
  <p>EDIT: Here are the JS files I'm trying to use can be viewed here:</p>
  
  <p><a href="http://www.automatastudios.com/clients/cco/inpractice/css/inPractice.css" rel="noreferrer">http://www.automatastudios.com/clients/cco/inpractice/css/inPractice.css</a>
  <a href="http://www.automatastudios.com/clients/cco/inpractice/css/inPracticeScheme.css" rel="noreferrer">http://www.automatastudios.com/clients/cco/inpractice/css/inPracticeScheme.css</a>
  <a href="http://www.automatastudios.com/clients/cco/inpractice/css/screen.css" rel="noreferrer">http://www.automatastudios.com/clients/cco/inpractice/css/screen.css</a>
  <a href="http://www.automatastudios.com/clients/cco/inpractice/css/mobile/iPad.css" rel="noreferrer">http://www.automatastudios.com/clients/cco/inpractice/css/mobile/iPad.css</a></p>
  
  <ul>
  <li>NOTE: These CSS files were not authored by me.</li>
  </ul>