Re: Closing my Window after Download
| From: | Miles Thompson | Date: | Thu, 26 Aug 2004 13:33:14 +0000 |
| Subject: | Re: Closing my Window after Download | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194778@lists.php.net to get a copy of this message | ||
At 09:14 AM 8/26/2004, PHP Junkie wrote:
Ave, Trust me John, I would not post here without trying out "many" javascript functions first. In fact, the reason I posted here is because I began to think that a PHP script like that won't allow the window to close, because from window.close() to self.close() to various "Timeout & Close" scripts, I've tried many javascript functions. I don't get any errors ... The window just doesn't close... On 8/24/04 2:09 PM, "John Nichel" <john@kegworks.com> wrote: PHP Junkie wrote:Here, try this JS:PHP cannot do this. You'll have to use JavaScript in the browser window. Something like.... <?php $file = "$P/$F"; header("Content-Description: File Transfer"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".basename($file)); @readfile($file); ?> <script language="JavaScript"> window.close(); </script>Ave, The browser window which launched the Save As window...
function close_opener()
{
parentwin = window.self; // Make handle for current window named "parentwin"
parentwin.opener = window.self; // Tell current window that it opened itself
parentwin.close(); // Close window's parent (e.g. the current window)
}
HTH - Miles Thompson