title: How to download the current page as a file / attachment using Javascript?
body: <p>I am aware of the hidden iFrame trick as mentioned here (http://stackoverflow.com/questions/365777/starting-file-download-with-javascript) and in other answers.</p>
  
  <p>I am interested in a similar problem:</p>
  
  <p>How can I use Javascript to download the <em>current</em> page (IE: the current DOM, or some sub-set of it) as a file?</p>
  
  <p>I have a web page which fetches results from a <em>non-deterministic</em> query (eg. a random sample) to display to the user. I can already, via a querystring parameter, make the page return a file instead of rendering the page. I can add a "Get file version" button (our standard approach) but the results will be different to those displayed because it is a different run of the query.</p>
  
  <p>Is there any way via Javascript to download the current page as a file, or is copying to the clipboard my only option?</p>
  
  <p><strong>EDIT</strong>
  An option suggested by Stefan Kendall and dj_segfault is to write the result server side for later retrieval. Good idea, but unfortunately writing files server side is out of the question in this instance.</p>
  
  <p>How about <em>shudder</em> passing the <code>innerHTML</code> as a post parameter to another page?</p>