I'm clearly missing something and I've been looking for a solution for hours
without a clue.
Objective: Create a typical "download" link using JS window.open. I get the
window to open, the "Save As" box appears, and the file ends up where I want
it, with the right name, the problem is that the child window doesn't go
away (save IE). Mozilla Firefox (PC and Mac), Safari, and all others I've
tested leave the child window. If I do a win.close() the child window
appears and disappears so fast that the SaveAs never shows up. I've tried
using a setTimeout() call to delay this a bit until everything is ready, but
that doesn't do it. What am I missing? Do I need a redirect? If so, where?
I'd like to leave the original page intact/untouched.
Here's my code snippet. Assume "myprog.php " has all the proper sense to send
the right HTTP headers and such.
<script language="JavaS cript">
function dlFile(file)
{
var win
=window.open(fi le,'dlnow','too lbar=0,location =no,directories =0,status=0,
scrollbars=no,r esizable=yes,wi dth=1,height=1, top=0,left=0');
win.focus();
// win.close(); // Causes the program to die before the DL starts
}
var dlnl = "dlFile('ht tp://myserver/myprog.php?Open =127967')";
document.write( '<a href="javascrip t:' + dlnl + '">Download</a>');
</script>