I have a page that displays results of a database search.  The page contains
a select dropdown box from which the user can pick different options
including the ability to download an Excel or CSV file of the displayed
results.  Once the user selects an option from the dropdown, a Javascript
onchange method will kick in, submit the form and process the selected
option.  If the option is one of the file download choices, then using
Javascript a new, child window will be opened and the location of the child
will be the PHP download script with the file to download.  The script in
the child window will force the browser's download dialog box to open up at
which point the user can save, open, or cancel the file download.  The issue
that I have is that some browsers (IE6) will automatically close the child
window when the user has made a selection from the download dialog box while
other browsers (Mozilla) will leave the child window remaining open.  I need
to either come up with a way to close the child window once the user has
finsished with the download dialog or force the download script to not run
in a child window.  I've thought about applying a timer somewhere but this
isn't reliable because of the unknowns of file download time and user
response time to the download dialog.  I don't have a preference as to
whether the solution is all PHP based, all Javascript, or a mix of both -- I
just need a solution to close this child window when complete.

Code is below.  As usual, thanks in advance.

Dave Merritt

Javascript code from the parent search results window opening the child
window & calling the PHP download script:

<SCRIPT type= "text/javascript" language="JavaScript">
DownloadWindow ="../functions/download.php/?Filename=<?echo
$Filename?>", "Download", "toolbar=0, location=0, directories=0, status=0,
menubar=0, scrollbars=0, resizable=0, copyhistory=0, width=200,


if (isset($_GET['Filename']))
    if ( $_GET['Filename'] != '' )
        $Filename = $_GET['Filename'];
        header("Content-Disposition: inline; filename=" .
        header("Content-Type: application/octet-stream");
        header("Content-Type: application/force-download");
        header("Content-Type: application/download");
        header("Content-Transfer-Encoding: binary");
        header("Content-Length: " . filesize($Filename));
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
Any views, opinions or authorizations contained in this email are solely those of the 
author and do not necessarily represent those of ArvinMeritor, Inc. If you are not 
familiar with the corporate authority of the author, please obtain confirmation in 
of the content of this email prior to taking any action on the basis of the 
information. If 
you are not the intended recipient, you are hereby notified that any disclosure, 
or distribution of the information enclosed is strictly prohibited. 

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to