Hi,
I have a php generated HTML page, which has a javascript call in the
body tag:
<body onunload="exitPage()" onload="setWidth()" onresize="setWidth()">
In certain cases, there can be an iframe in the page:
<iframe src="/secure/download.php?dl_file=test.txt" style="display:
none" />
This technique has been mentioned by Chung Leong in several posts to
open a file save dialog in the browser (and load the HTML page at the
same time .. 2 HTTP requests).
The problem is:
in Firefox, all works fine, the page loads, the javascript setWidth is
called for onload, and the file dialog appears.
but,
In IE 6, the file dialog shows, but the javascript onload event is
never triggered.
Can anyone help please. Am I missing something here? Any way to get
around this problem in IE?
Thanks,
Saayan
The /secure/download.php looks like this:
<?php
if(!empty($_GET['dl_file']))
{
// check the valid files here
// and don't accept random requests
// potentially naughty :)
// can read the db here for valid list
// TODO
// now only one file, so don't make this
// complex
if($_GET['dl_file'] == 'test.txt')
{
header("Content-type: application/octet-stream");
$filename = $_GET['dl_file'];
header("Content-disposition: attachment; filename=\"$filename\"");
$path = dirname(__FILE__)."/../download";
readfile("$path/$filename");
exit();
}
}
?>