...

View Full Version : how know when popup window closes ?



adamoneil
01-20-2006, 04: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?

martin_narg
01-20-2006, 04:57 PM
try this:


// main page:
function foo(str) {
alert(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);">
.....
</form>
hope this helps

m_n

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum