title: Auto-closing a popup with a file to download
body: <p>I have a file, named <code>download.php</code>, which contains a file to be downloaded, so it has the following headers (declared with PHP):</p>
  
  <pre><code>header("Content-Type: ".pathinfo($_GET['file'], PATHINFO_EXTENSION));
  header("Content-Length: ". filesize($_GET['file']));
  header("Content-Disposition: attachment; filename=". $_GET['file']);
  </code></pre>
  
  <p><code>download.php</code> is opened as a popup with jQuery by an other page.</p>
  
  <p>Now I want <code>download.php</code> to self-close (using JavaScript) after some seconds (so I'm secure that download started) but I didn't manage to write working code.
  Here are the codes I tried (I placed them <em>after</em> headers):</p>
  
  <pre><code>window.setTimeout('self.close();', 3000);
  window.setTimeout('function(){self.close();}', 3000);
  window.setTimeout(self.close();, 3000);
  </code></pre>
  
  <p>I also tried simply:</p>
  
  <pre><code>self.close();
  </code></pre>
  
  <p>but it does not work anyway.</p>
  
  <p>I tried to put these codes both in <code>&lt;head&gt;</code> and in <code>&lt;body&gt;</code>.</p>
  
  <p>What could be the problem?</p>