Page 1 of 1

help: How to auto close pop up when finished.

Posted: Sun Oct 12, 2003 3:48 am
by camarosource
We want to have it so when a HTML form is submitted (a person is uploading a picture) that a Javascript will open a pop up window and then automatically close the window once the file is sent sucessfully.

See, we use like it's w = window.open(blah blah to open and w.close() to close but when the form is submitted w gets destroyed, so we need a way to close it without w or pass w to the next page or need a way for the popup to check when form is done submitting so it can close itself

Does anyone know a good way to do this?

Thanks

Posted: Sun Oct 12, 2003 5:38 am
by delorian
In the document which will be opened in that pop-up window. You should put the following line:

Code: Select all

<body onLoad="window.close();">
If I catch what you're up to. :D

Posted: Sun Oct 12, 2003 7:49 am
by JAM
A reminder, that you can pass variables using $_GET (http://example.com/page.php?something=here) also, that later can be inserted into javascript. Might be useful.

Posted: Sun Oct 12, 2003 10:48 am
by Vincent Puglia
Hi,

Sorry, I didn't fully understand the problem this morning in the other forum.

in the original page:
w = window.open('w.html');
location='x2.html'

in the x2 page:
nothing relevant to the problem

in the w document:
function doit()
{
if (opener.location.toString().indexOf('x2.html') != -1) this.close();
setTimeout('doit()', 1000);
}

setTimeout('doit()', 1000)

Vinny