• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 557
  • Last Modified:

HELP: popups children and parent

I have one main popup window with some javascript functions.
Clicking on a link opens a child popup window.

I don’t know how those two popup windows can collaborate in javascript?
By collaborate I mean few things:
-how I can call javascript functions from parent code in child popup code?
-how can I close parent popup from the child’s code
-if parent popup has ActiveX component, can I set some property of that ActiveX from the child popup window?

Please give some code examples….
0
glowas
Asked:
glowas
2 Solutions
 
jaysolomonCommented:
opener function

function helloworld(){
     alert("Hello World");
}

call it in the child like so

<a href="#" onclick="opener.helloworld();return false;">Hello World</a>

Close the popup
<a href="#" onclick="self.close();return false;">Close Me</a>


I do not use activeX and do not allow them to be run on my boxes so cannot help on those
0
 
searlasCommented:
Most of this is addressed in the answers to this question:
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_20927049.html
0
 
alambresCommented:
in main win:
var win1 = window.open ("popup1.htm","", "");
var win2 = window.open ("popup2.htm","", "");

to call functions defined in the parent from the popup:
>> supposing function myFunc(){}

window.opener.myFunc();
>> supposing function myFunc2(){}

to call functions defined in the popup from the parent:

win1.myFunc2();

to call functions defined in one popup from the other:
>> supposing function myFunc3(){}  defined in the second popup:

in the first popup   ----  
window.opener.win2.myFunc3();

note that you must check if the window you wanna refer is opened (that is exists):
if (!win1.closed) win1.myFunc();



0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
glowasAuthor Commented:
Thanks for the response guys.
I'll test it now.
One more thing:
-How to close all child popups when closing the parent window?
0
 
alambresCommented:
should remember someway the vars referring to the popups
0
 
alambresCommented:
for Mozilla:
var win1 = window.open ("popup1.htm","", "dependent");
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now