title: Open/Save local (JSON) file from JavaScript >> IE/Firefox
body: <p>I'm very new to JS and I'm doing a small html page that -for now- will be ran locally.  I have a string in JSON format which I need to be able to store/load as a file on the hard drive.</p>
  
  <p>To be able to store the string, I've got this to work on Firefox:</p>
  
  <pre><code>function saveJSON() {
      var obj = {name:'John', max:100};
      window.open( "data:text/json;charset=utf-8," + escape(JSON.stringify(obj)))
  }
  </code></pre>
  
  <p>However, it only works on FF, and I need to be able to do it with Internet Explorer also.  I've read some stuff about using ActiveX, but I haven't found any example on how to do it.</p>
  
  <p>Should I try and use ActiveX, or is there a better HTML/JS way to save the file which works for both browsers?</p>
  
  <hr>
  
  <p>The second problem is loading the JSON file.  I've found that once loaded, I can turn it into a JSON var with JSON.parse.  But I have no idea how to load a selected JSON file.  I have an </p>
  
  <pre><code>&lt;input type=file id="filePath"&gt; 
  </code></pre>
  
  <p>to get the file path (though it returns different things in both browsers), and I would like to be able to do something like </p>
  
  <pre><code>var a = loadFile(filePath.value)
  </code></pre>
  
  <p>Any suggestions on how to do it? I'm really stuck here and would greatly appreciate any help.</p>
  
  <p>Thanks.</p>