Page 1 of 1
Closing browser windows
Posted: Wed Apr 02, 2003 1:23 am
by Seitan end Yvl
hi, to all.
I have slight problem:
i want my php file to open download box for user with file, i want to download, so i use current command:
echo "<script>location='somefile.zip'</script>";
but now, i want my page to close after 5 seconds.
how may i do that?
Posted: Wed Apr 02, 2003 2:22 am
by twigletmac
You can't close pages using PHP you need to use something client-side like JavaScript.
Mac
code
Posted: Wed Apr 02, 2003 2:25 am
by Seitan end Yvl
coud you help me out with some code example, please?
Posted: Wed Apr 02, 2003 2:29 am
by twigletmac
nope
Posted: Wed Apr 02, 2003 3:44 am
by Seitan end Yvl
Nope, the same bug :)
echo '<script language="JavaScript">';
echo 'function closeWin() {';
echo ' setTimeout("window.close();", 5000);}';
echo "</script>";
echo "<script>location='closeWin()'</script>";
echo "<br><br>Window will close in 5 seconds";
echo "<script>location='somefile.zip'</script>";
works only the LAST script, - if the last will be
echo "<script>location='somefile.zip'</script>";
opens download dialog box, but window does not close, if the last is
echo "<script>location='closeWin()'</script>";
window closes, but no dialog is displayed.
Posted: Wed Apr 02, 2003 6:00 am
by d1223m
echo "<script>location='closeWin()'</script>"; #
think about that line
:)
Posted: Wed Apr 02, 2003 7:18 am
by Seitan end Yvl
no idea...
tried to use
echo "<script>location='javascript:closeWin()'</script>";
the same problem :(
Posted: Wed Apr 02, 2003 9:18 am
by d1223m
all that line does is set the variable location to the string 'closeWin()'
how about you just call the function :)
Posted: Sat Apr 05, 2003 4:04 am
by Skyzyx
Code: Select all
<script language="Javascript" type="text/javascript">
<!--
setTimeout("window.close();", 5000);
//-->
</script>