So, I'm doing the following in a php script so that I can fire a
download dialogue AND redirect the page (after clicking submit in a
form). I'm doing it this way because of the problem with headers and
such and server-side vs client-side issues:
$dir = "somedir";
$file = "somefile";
print("
<script language=\"JavaScript\">
<!--
my_window =
window.open('get.php?dir=packages$dir&file=$file','Downloading','width=1,height=1,resize=no');
window.location.href = '$redirpage';
setTimeout('window.close()', 5000);
//-->
</script>");
Everything works here EXCEPT for the closing of the d**n empty window
that is opened. My get.php fires to open a new dialogue to download
the file I want, the page I was on gets redirected to $redirpage, but
the empty window doesn't close. If I DON'T use setTimeout and just do
the following:
print("
<script language=\"JavaScript\">
<!--
my_window =
window.open('get.php?dir=packages$dir&file=$file','Downloading','width=1,height=1,resize=no');
window.location.href = '$redirpage';
my_window.close();
//-->
</script>");
then the window closes but too fast for the get.php to pop up the
download dialogue (hence my need to delay the close of the window a
bit). I've tried using setTimeout('my_window.close()', 5000); but the
empty window never closes. This is driving me nuts as it appears it
should be fairly straight forward. Any assistance is greatly
appreciated. (BTW, I'm fairly novice at this so any better ideas on how
to do what I'm trying to do is also greatly appreciated).
Thanks.
Kevin
Martin Kurz - 30 Aug 2005 22:44 GMT
kevinm3574 schrieb:
> So, I'm doing the following in a php script so that I can fire a
> download dialogue AND redirect the page (after clicking submit in a
[quoted text clipped - 13 lines]
> //-->
> </script>");
in this variant, you would close the main-window, not the popup. You want to
close my_window, not this window. But the Problem is an other: Your're leaving
the page, that has the information about the popup-window and setTimeout (AFAIK)
don't survives a location-change. So something like this should work:
my_window.setTimeout('self.close()', 5000);
This way, you're applying the Timeout to the popup-Window.
Greetings,
Martin
kevinm3574 - 31 Aug 2005 15:52 GMT
Martin,
Thanks!!! That works great. I appreciate your responding.
Kevin