473,320 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to close a child window?

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
2 18678


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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joe D | last post by:
I think this is a simple question. But I am new to JS. Here is what I want to do: From a parent window, open a popup window (child) to get data from user, then user submit the request, close the...
6
by: | last post by:
In IE, from the child window of a frameset i use the function top.window.close() And this works in IE, but not in nn4! How can i make this same effect in nn4? please help
28
by: PerryC | last post by:
Anyone know how to auto close the parent / opener window without confirmation? I have tried: <script> opener.window.close() </script> ----I put it in the child html page, and nothing...
1
by: gopal srinivasan | last post by:
I need to know how to close a parent modal window when child modal window opens, also i need to know the syntax for writing document on the modal window on the fly, like what we do in case of...
3
by: Isabel | last post by:
How can you close all child browser windows that where open by a parent browser window? I have links on a parent (main) page that opens the child page as a separate browser. However, I need to be...
2
by: Paul | last post by:
Hi this is related to a previous post, hopefully just a bit clearer description o the problem. I have a parent form that opens a new form (child form) while still leaving the parent form open....
3
by: Volodymyr Lozovoy | last post by:
Help novice I open new window using window.open(), then user click button in this window and i create file and return it user using Response.Redirect(fileName). How i can close the window after...
7
by: Jaggu | last post by:
Hi , I need to close main window, once the child window succesfully opens else main window to remain. In my case when I close the main window immediately after the "window.open()" as mentioned...
1
by: michal.podlewski | last post by:
Hi All, I have a problem with a simple (as I thought till now) thing: I want to make a link in a child-window which would change site in the parent-window and along with closing child window. The...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.