View Full Version : how know when popup window closes ?

01-20-2006, 05:54 PM
I'm creating a popup window like this:

var win = window.open(blah blah blah)

I want to be able to tell in my calling page when the popup window closes, or better yet, when the form on the popup is submitted. I have tried this:

var win = window.open(blah blah blah);
win.onunload = MyUnloadFunction;

but it doesn't work; my onunload handler isn't called.

What am I missing?

01-20-2006, 05:57 PM
try this:

// main page:
function foo(str) {

// in the popup
function validate(theForm) {
// perform validation on your form here

// call to the opening page *after* any validation refusals
if(opener && !opener.closed) {
opener.foo("the opener posted a form");
return true;

your popup form:

<form name="frm" ..... onsubmit="return validate(this);">
hope this helps


01-24-2006, 01:59 AM
Wow! Thank you.