I have an application that queries an Oracle database and outputs records in HTML. I want to be able to allow users to output to Excel this way, as well as to the browser. On the query form, I currently let the user check a checkbox if they want an Excel ouptut also. If the box is checked, I use a Javascript to open another window:
print "<script language='javascript'>
window.open('$APP->wwwroot/records/record_report.php?query=$encode')
</script>";
The first thing outputted by record_report.php is the header MIME type:
header("Content-Type: application/vnd.ms-excel");
After the MIME type is read, the server knows that the data is to be opened with Excel. This action allows me to output the data to Excel, but it always leaves a blank browser window after I open it with Javascript. This is because Script opens the window, an only then does the server know it is to be Excel, so it opens Excel after that. I ONLY want the Excel part.
Is there any way to stop this from happening? I've tried to use a setTimeout() Javascript to close the window after a couple of seconds, but need a better solution.