title: javascript file download
body: <p>I need to download a file (test.xml) and allow/prompt user to save the file on click on download button. The file resides in url "http://localhost/test/test.xml" .</p>
  
  <p>I have added html code </p>
  
  <pre><code>&lt;input type=button value="Download" onclick='javascript:download()/&gt;
  </code></pre>
  
  <p>and javascript code is </p>
  
  <pre><code>function download() {
     var url = "http://localhost/test/test.xml";
         window.open(url, 'Download');
  }
  </code></pre>
  
  <p>But this opens the page in new window. How do I prompt to download and save the file. Any inputs will be of help. Thanks</p>