Welcome Guest, Not a member yet? Register   Sign In
Closing the page after downloading
#1

[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?
#2

[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()
#3

[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.
#4

[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.




Theme © iAndrew 2016 - Forum software by © MyBB