CodeIgniter Forums
Closing the page after downloading - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Closing the page after downloading (/showthread.php?tid=3383)



Closing the page after downloading - El Forum - 09-27-2007

[eluser]New One[/eluser]
Hello All,

I want mi code to do this:
after pressig download - the download screen appears and in the same time previous window is closing.

controller:
function download(){
$basePath = 'c:/';
$data = file_get_contents("$basePath/instructions.txt");
$name = "instructions.txt";
force_download($name, $data);
}


view:


function GoClose()
{
//window.close();
}


<?=form_open('/test/download/', $data)?>
<?echo '<input type="image" name="submit" onmousedown = "GoClose()" src="/images/down.png" />';?>
<?=form_close();?>


Something like this. Can someone help me?


Closing the page after downloading - El Forum - 09-27-2007

[eluser]Code Arachn!d[/eluser]
if you are using the download helper - it should take care of pushing the download window to the browser. So my recommendation is using JavaScript to close any windows you have open. Placing this in a link tag should be what you're looking for:
Code:
self.close()



Closing the page after downloading - El Forum - 09-28-2007

[eluser]New One[/eluser]
Thanks, Sad But it does not helps. Now window closes before pushing the download window to the browser. So window closes and nothing happens.


Closing the page after downloading - El Forum - 09-28-2007

[eluser]Code Arachn!d[/eluser]
well unless you have a way of telling if the download is successful then it wouldn't make sense to close the window... one way to try (I'm not 100% if this will even work) is to use this after the force_download
Code:
redirect('close_page');
and have the close_page have js code that will close the window.