title: Creating an export function with JavaScript?
body: <p>I'm trying to set up an export function in JavaScript for a packaged web app that turns a string stored in localStorage into a plain text file for downloading. As JavaScript does not have access to the computer's file-system, I'd like to set it up so that it create a blank text file (or, failing that, a simple HTML page) and open in in the web-browser; as it wouldn't be accessing any file-systems I was hoping this would be possible.</p>
  
  <p>I was thinking of using a Data URI scheme to open the localStorage as plain text, such as the following:</p>
  
  <pre><code>function exportFile() {
   window.open("data:text/plain;charset=utf-8," + localStorage.WebAppData);
  };
  </code></pre>
  
  <p>But it's much slower than I expected, which I guess is because it's sticking the whole document in the URL box. Though probably not an issue with the code, some web browsers, like Google Chrome, won't let me save the resulting file. (And for some reason all the line-breaks have turned into spaces....)</p>
  
  <p>Any suggestions to fix these problems or better ways of doing a similar function will be greatly appreciated!</p>