title: Force IE to Open a Download in a new window
body: <p>I have web app that lists files stored inside it.</p>
  
  <p>Each item has a hyperlink that, when clicked, forces the Open/Save dialog to appear.</p>
  
  <p>Now, if I click on a link pointing to, say, a Word document and select 'Open' it opens in it's own window, as you would expect. However, if the file is an HTML file and I select the 'Open' option it opens to page in the browser [correct] but it opens in the window I used to select the document [bad].</p>
  
  <p>So, to the question: Is it possible to force the 'Open' option of the Open/Save dialog to open a document in a new window?</p>
  
  <p><strong>Edit:</strong>
  The hyperlink that forces the document to be opened is not just a pointer to the file (for a number of reasons). The .NavigateUrl property contains a call to a JavaScript function, This function makes an Ajax request to the app proper, which fetches the document from secure storage and presents it to the user's browser as an attachment (Content-Disposition: attachment)</p>
  
  <p><strong>Further Edit:</strong>
  The JavaScript function simply makes an Ajax call back in to the page. The result of <em>this</em> action is to cause a page to be displayed in an IFrame. This page write directly to the Response Object as follows:</p>
  
  <pre><code>Response.ContentType = "application/octet-stream";
  Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", FileName));
  Response.AddHeader("Content-Length", String.Format("{0}", length));
  Response.Flush();
  Response.Close();
  </code></pre>
  
  <p>I suppose, if it <em>is</em> possible to change the action of the 'Open' button in the resulting Open/Save dialog, it's going to be something I do in <em>this</em> code that will force it.</p>
  
  <p>If it makes a difference, this is a .Net v4.0 app written in C#.</p>
  
  <p>I know about the good and bad of opening new windows, but this is a private app and it's what the client wants.</p>