By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,143 Members | 855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,143 IT Pros & Developers. It's quick & easy.

how to close a child window?

P: n/a
Process:
I have a form which uploads a file from client to server written in PHP.
When the user presses the submit button, I use the "onSubmit" event to
execute javascript to open a child window containing some text and an
animated GIF. The javascript returns 'True' and the file is uploaded. All of
that works great.

Problem:
Now I am trying to close the child window after the file has been uploaded.
Below is the JavaScript I'm using:

Observations:
Error Msg: "progress is undefined".
I have observed that after form submission the 'if' statement in the 'close
child window' code fails because the handle 'progress' appears to have no
value. My guess is that on form submission the handle 'progress' looses its'
value because the action for the form is to reload itself. The 'if' staement
does execute because I have placed an 'alert' statement just prior to it an
the 'alert' executed appropriately.

If I try to open the window after submitting the form, the page doesn't open
until after the file has been uploaded, which defeats the purpose.

Question:
How do I close the window after the form has been submitted?

Thanks for your help!
Irvin.
__________________________________________________ _____

Javascrtip Code:
__________________________________________________ _____

To open the child window:
<script language="javascript">
var progress=null;
function sendfile() {
progress=window.open('test2.htm','progress','width =350,height=475');
return true;
}
</script>

To close the child window:
This code follows my PHP code that verifies the file upload.
<script type="text/javascript" language="javascript">
if (progress && !progress.closed) {
progress.close();
}
</script>
__________________________________________________ ______
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


Irvin Amoraal wrote:
Process:
I have a form which uploads a file from client to server written in PHP.
When the user presses the submit button, I use the "onSubmit" event to
execute javascript to open a child window containing some text and an
animated GIF. The javascript returns 'True' and the file is uploaded. All of
that works great.

Problem:
Now I am trying to close the child window after the file has been uploaded.
Below is the JavaScript I'm using:

Observations:
Error Msg: "progress is undefined".
I have observed that after form submission the 'if' statement in the 'close
child window' code fails because the handle 'progress' appears to have no
value. My guess is that on form submission the handle 'progress' looses its'
value because the action for the form is to reload itself. The 'if' staement
does execute because I have placed an 'alert' statement just prior to it an
the 'alert' executed appropriately.

If I try to open the window after submitting the form, the page doesn't open
until after the file has been uploaded, which defeats the purpose.

Question:
How do I close the window after the form has been submitted?

Thanks for your help!
Irvin.
__________________________________________________ _____

Javascrtip Code:
__________________________________________________ _____

To open the child window:
<script language="javascript">
var progress=null;
function sendfile() {
progress=window.open('test2.htm','progress','width =350,height=475');
return true;
}
</script>

To close the child window:
This code follows my PHP code that verifies the file upload.
<script type="text/javascript" language="javascript">
if (progress && !progress.closed) {
progress.close();
}
</script>


That doesn't help, on a new page the variable progress is not defined.
All you can do on a new page is
window.open('', 'progress').close();
That way the window with name progress will be closed. Only shortcoming
is if the user has already closed the window it will be reopened and
then directly closed again.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

P: n/a
That did the trick.
Thanks.
________________________

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:3f********@olaf.komtel.net...


Irvin Amoraal wrote:
Process:
I have a form which uploads a file from client to server written in PHP.
When the user presses the submit button, I use the "onSubmit" event to
execute javascript to open a child window containing some text and an
animated GIF. The javascript returns 'True' and the file is uploaded. All of that works great.

Problem:
Now I am trying to close the child window after the file has been uploaded. Below is the JavaScript I'm using:

Observations:
Error Msg: "progress is undefined".
I have observed that after form submission the 'if' statement in the 'close child window' code fails because the handle 'progress' appears to have no value. My guess is that on form submission the handle 'progress' looses its' value because the action for the form is to reload itself. The 'if' staement does execute because I have placed an 'alert' statement just prior to it an the 'alert' executed appropriately.

If I try to open the window after submitting the form, the page doesn't open until after the file has been uploaded, which defeats the purpose.

Question:
How do I close the window after the form has been submitted?

Thanks for your help!
Irvin.
__________________________________________________ _____

Javascrtip Code:
__________________________________________________ _____

To open the child window:
<script language="javascript">
var progress=null;
function sendfile() {
progress=window.open('test2.htm','progress','width =350,height=475'); return true;
}
</script>

To close the child window:
This code follows my PHP code that verifies the file upload.
<script type="text/javascript" language="javascript">
if (progress && !progress.closed) {
progress.close();
}
</script>


That doesn't help, on a new page the variable progress is not defined.
All you can do on a new page is
window.open('', 'progress').close();
That way the window with name progress will be closed. Only shortcoming
is if the user has already closed the window it will be reopened and
then directly closed again.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.