Click to See Complete Forum and Search --> : javascript problem


cafrow
07-19-2005, 05:52 PM
Hi there. I am using PHP to upload a file and would like to make a window popup when the Submit button is pressed to start the file upload. I have this part working so far, the part I am having a hard time with it Closing the child (popup) window once the file is finished being uploaded. I have tried to do this on the onUnLoad event of the upload script and also on the refresh of the page once the upload is done and cannot get it to work for the life of me.

I have searched online and was unable to find info on closing the child popup from the parent, there is plenty of info on closing the parent from the child.

Thanks for any help.

planetsim
07-19-2005, 07:42 PM
Is this really a Windows problem?

This code, which you will need to modify slightly should work.

<script type="text/javascript">

var opener;

function windowopen()
{
opener = window.open('test.html', 'test', 'width=400;height=200;');
}

function windowclose()
{
opener.window.close();
}

</script>


I just used 2 links on the parent from like this
<a href="#" onclick="windowopen();">Open</a> <a href="#" onclick="windowclose();">Close</a> As you can tryout, it should close the opened window from the parent.

cafrow
07-19-2005, 08:11 PM
thank you, that worked perfectly. I put the opener.window.close in the onunload event of the parent window. THank you so much.