title: Set headers using javascript
body: <p>I need to download a file from a web service which uses basic authentication. This means I need to add an authorization header to the request. I know how to do this using jQuery Ajax, but I CANNOT use Ajax since I need to download a file from the url and Ajax requests cannot download files to disk.</p>
  
  <p>How can I set the authorization header before I do <code>window.location = url</code> ?</p>
  
  <p>I searched the web, but everything I find is about jQuery Ajax which I cannot use.</p>