...

View Full Version : help: How to auto close pop up when finished.



camarosource
10-12-2003, 09:36 AM
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

sciguyryan
10-12-2003, 11:55 AM
I think that this is in the wrong forum - havent i seen this post some where else too?

sciguyryan
10-12-2003, 11:56 AM
you could use the tineout function to do that.

nolachrymose
10-12-2003, 03:21 PM
You could have an onsubmit handler like this:


<form ....onsubmit="openwin(location.href); return true;">

...with the openwin() function along the lines of this:


function openwin(loc) {
var x = window.open();
x.document.open();
x.document.write("Please wait, processing.....");

setInterval(function() { if(opener.location.href != loc) x.window.close(); }, 100);

I *think* that will work.

Hope that helps!

Happy coding! :)

glenngv
10-13-2003, 09:52 AM
put this in the page after form submission:

<script type="text/javascript">
var popup = window.open("","nameOfPopup");
if (popup && !popup.closed) popup.close();
</script>

That will do the trick. Just specify the same target name used in opening the popup in the previous page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum