Solved

HELP: popups children and parent

Posted on 2004-03-25
6
549 Views
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….
0
Comment
Question by:glowas
6 Comments
 
LVL 16

Expert Comment

by:jaysolomon
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
0
 
LVL 7

Accepted Solution

by:
searlas earned 200 total points
ID: 10677497
Most of this is addressed in the answers to this question:
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_20927049.html
0
 
LVL 5

Assisted Solution

by:alambres
alambres earned 300 total points
ID: 10677523
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:glowas
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?
0
 
LVL 5

Expert Comment

by:alambres
ID: 10677971
should remember someway the vars referring to the popups
0
 
LVL 5

Expert Comment

by:alambres
ID: 10678069
for Mozilla:
var win1 = window.open ("popup1.htm","", "dependent");
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

785 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