Closing browser windows

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Seitan end Yvl
Forum Newbie
Posts: 4
Joined: Wed Apr 02, 2003 1:23 am
Location: Lithuania
Contact:

Closing browser windows

Post 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?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You can't close pages using PHP you need to use something client-side like JavaScript.

Mac
User avatar
Seitan end Yvl
Forum Newbie
Posts: 4
Joined: Wed Apr 02, 2003 1:23 am
Location: Lithuania
Contact:

code

Post by Seitan end Yvl »

coud you help me out with some code example, please?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

User avatar
Seitan end Yvl
Forum Newbie
Posts: 4
Joined: Wed Apr 02, 2003 1:23 am
Location: Lithuania
Contact:

nope

Post 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.
User avatar
d1223m
Forum Commoner
Posts: 80
Joined: Mon Mar 31, 2003 5:15 am
Location: UK, West Sussex

Post by d1223m »

echo "<script>location='closeWin()'</script>"; #

think about that line
User avatar
Seitan end Yvl
Forum Newbie
Posts: 4
Joined: Wed Apr 02, 2003 1:23 am
Location: Lithuania
Contact:

:)

Post by Seitan end Yvl »

no idea...
tried to use
echo "<script>location='javascript:closeWin()'</script>";
the same problem :(
User avatar
d1223m
Forum Commoner
Posts: 80
Joined: Mon Mar 31, 2003 5:15 am
Location: UK, West Sussex

Post by d1223m »

all that line does is set the variable location to the string 'closeWin()'

how about you just call the function :)
Skyzyx
Forum Commoner
Posts: 42
Joined: Fri Feb 14, 2003 1:53 am
Location: San Jose, CA

Post by Skyzyx »

Code: Select all

<script language="Javascript" type="text/javascript">
<!--

setTimeout("window.close();", 5000);

//-->
</script>
Post Reply