HELP: popups children and parent

Posted on 2004-03-25
Last Modified: 2008-03-17
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….
Question by:glowas
LVL 16

Expert Comment

ID: 10677484
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

Accepted Solution

searlas earned 200 total points
ID: 10677497
Most of this is addressed in the answers to this question:

Assisted Solution

alambres earned 300 total points
ID: 10677523
in main win:
var win1 = ("popup1.htm","", "");
var win2 = ("popup2.htm","", "");

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

>> supposing function myFunc2(){}

to call functions defined in the popup from the parent:


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

in the first popup   ----  

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center


Author Comment

ID: 10677948
Thanks for the response guys.
I'll test it now.
One more thing:
-How to close all child popups when closing the parent window?

Expert Comment

ID: 10677971
should remember someway the vars referring to the popups

Expert Comment

ID: 10678069
for Mozilla:
var win1 = ("popup1.htm","", "dependent");

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question