PDA

View Full Version : How to detect popup is close from the parent window?


buckbeak
09-18-2002, 06:43 AM
I want to pass value from the popup to the parent. I did that using 'opener'. That's working very well.

My problem now is, the value is displayed on the parent window but I want to use the value to execute a query. Can that be done?

So in the parent, when the popup is close, execute the query with the value passed without refreshing the page. I'm integrating this with cold fusion programming.

Please help!

martin_narg
09-18-2002, 07:43 AM
as you pass your variable back to opener do it via a function that posts a hidden form, for example:


opener:
<script>
function postForm(str) {
document.myForm.name.value = str;
document.myForm.submit();
}
</script>
<form name="myForm" method="POST" action="formHandler.asp">
<input type="hidden" name="name">
</form>



popup:
<script>
function passName() {
opener.postForm(document.nameForm.name.value);
window.close;
}
</script>
<form name="nameForm">
input type="text" name="name">
<br>
<input type="button" value="submit" onClick="passName()">
</form>


The page "formHandler.asp" would then do your query based on the "name" value that is posted to it.

Hope this helps.

m_n

buckbeak
09-18-2002, 07:52 AM
I have already did that. I just want to know how to detect from the opener (parent window) if the popup is close??

And another thing is how can i call a function in the parent window from the popup?

popup
--------

window.opener.start();


parent
--------

function start(){........}

glenngv
09-18-2002, 08:33 AM
you dont necessarily need to detect from the opener if the popup is closed. you can submit the opener from popup as martin_narg suggested.

yes you call the function in opener from popup like that
window.opener.start()