Close window after download

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Close window after download

Post by pickle »

Hi All,

Here's what I want to do:

A user clicks a link to download some text (from a PHP file)
That PHP file generates the text, and dumps the content. The user is then prompted to download the file.

Code: Select all

<?PHP
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=test.txt");
echo "Contents of file";
?>
However, this is where my problem is. After the user has downloaded the file, they're stuck with a big dump blank window in the middle of their screen. Is there any way to get rid of this window?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

have you tried linking to it directly? without opening a window? i had this problem aswell, i just linked to the php page and it works.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

" Let the bells ring out
and the banners fly,
Qads, Qads,
Is quite a guy!"

It worked (as you may have already guessed). Thanks a bunch.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

lol, np :D
Post Reply