I have a popup window that prompts for a file download. HOwever I want the window to close after the user starts to download the file. I tried the following code but the window isn't closing (only if people click to NOT download the file). I don't understand why it's not closing. I am opening the popup window with a window.open command on the "main" page. <?php $filename= $_GET['file']; $filename=$filename.'.qqc'; header('Content-Description: File Transfer'); header('Content-Type: application/force-download'); header("Content-Disposition: attachment; filename=$filename; "); header('Content-Length: ' . filesize($filename)); ?> <script type="text/javascript"> window.close(); </script> PHP:
Since I don't know exact thing you are trying to do, I am just going take a guess-shot. Why you need to open popup window? If you set the content-type in out browser will give user option to save/open/cancel by itself (unless it can open it itself - like excel) If you have to submit the form, submit it to your main window it self - but the content type header in output will result into save/open/cancel dialog Hope this helps.
I'm doing other things on submit, I tried combining them into one php page but it's not really possible (because i'm doing more stuff before the filedownload). That's why I want to do it this way (it's also not uncommon). weknowtheworld, i'll try using a timer.
When the user clicks on the Download link, which you provide, do an onclick attribute to the link: "javascript:window.close();" Peace,