title: Export d3-generated HTML table as CSV (must work on IE too)
body: <p>From JavaScript, I make an ajax/xhr d3.csv() call which triggers a lengthy MySQL query (which can sometimes take more than 30 seconds to run).  An HTML table is then generated (<a href="https://stackoverflow.com/a/9507713/215945">via d3.js</a>) from the data.</p>
  
  <p>I want the user to be able to download the data as a CSV file via a button click, but</p>
  
  <ul>
  <li>I don't want to create a tmp file on the server for this</li>
  <li>Running the query again on the server is not an option -- I don't want to make the user wait another 30 seconds (nor tie up the database again)</li>
  <li>I want to specify the filename, e.g., <code>descriptiveName-some_datetime_here.csv</code></li>
  <li>It needs to work in IE (corporate America thing) and Safari (corporate Executive thing)</li>
  </ul>
  
  <p>Converting the JSON data that d3 created into CSV is not an issue (I know how to do that part).</p>
  
  <p>There are many similar SO questions, and the general consensus seems to be:<br> use a data URI and specify the filename in a <code>download</code> attribute (<a href="https://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side">Q1</a>, <a href="https://stackoverflow.com/a/7588465/215945">Q2</a>, etc.).<br>
  But that attribute is sadly <a href="http://caniuse.com/#feat=download" rel="nofollow noreferrer">not supported on IE or Safari</a>.</p>