title: javascript button to download a file
body: <p>I want to download a JSON(or XML) file by pressing a button. In HTML I define:</p>
  
  <pre><code>&lt;a id="exportJSON" onclick="exportJson()" class="btn"&gt;&lt;i class="icon-download"&gt;&lt;/i&gt; export json&lt;/a&gt;
  </code></pre>
  
  <p>In JavaScipt I have following code:</p>
  
  <pre><code>function exportJson() {
     var obj = {a: 123, b: "4 5 6"};
     var data = "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(obj));
     // what to return in order to show download window?
  }
  </code></pre>
  
  <p>I found a <a href="https://stackoverflow.com/questions/19721439/download-json-object-as-a-file-from-browser">very nice answer in Stackoveflow</a>, but I fail to adjust it into my problem, mainly show the download window. I do not want to create another link somewhere in the page (like done in above mentioned answer, just directly show download window).</p>