title: Using external JavaScript files in a WinForms/WPF WebBrowser control
body: <p>I found a cool feature on a website, implemented in JavaScript, I'd like to use it as is in my desktop application (for personal use). 
  During my experiments I managed to generate custom HTML on the fly, feed it to the browser using <code>webBrowser1.DocumentText = [my generated HTML]</code>
  I've managed to put some inline JavaScript into the HTML, and hook it up via a ScriptManager so that I can call the JavaScript from my C# code, pass a value to it, and get a return value.</p>
  
  <p>But the feature I'm trying to use is a bit more complicated: it's no less than 10 JavaScript files. 2 of them are referenced directly in the web page  the usual way <code>&lt;script src="/js/script1.js" type="text/javascript"&gt;&lt;/script&gt;</code></p>
  
  <p>The other 8 are loaded in one of the scripts:</p>
  
  <pre><code>var elem = document.createElement("script");
              elem.type = "text/javascript";
              elem.src = "/js/" + filename;
              document.body.appendChild(elem);
  </code></pre>
  
  <p>These 8 files are in fact data files, even though the data is represented in JavaScript. They're pretty large, over 1MB each. Stuffing it all into the HTML file seems quite stupid. Also, the script that loads the data creates a "file map" and further refers to the data based on which file it's in: </p>
  
  <pre><code>  var fileMap = [
                          [/[\u0020-\u00ff]/, 'file1.js'],
                          [/[\u3000-\u30ff]/, 'file2.js'],
                          [/[\u4e00-\u5dff]/, 'file3.js'],
  ...
  </code></pre>
  
  <p>I don't want to resort to modifying the JavaScript, because it's not exactly my strong point. So the browser needs to "see" the js files in order to be able to use them. I thought of creating the file structure locally, and navigating the browser there. But I don't want any loose files in my solution. I'd like to have everything embedded if possible. And I doubt I can get the browser to navigate to an embedded resource, and see other embedded resources as files. Any idea how I could get around this?</p>
  
  <p>EDIT:</p>
  
  <p>I've tried to do it with local files. No luck. I get the HTML to load properly, but when I try to invoke a JavaScript call, nothing happens. I tried pointing the browser to those js files, to make sure they're there. They are. I tried an  element with src attribute pointing to an image in the same subfolder as the script files. It gets rendered. It's as if external js files refuse to load.</p>