Solved

Close popup window if opener window closed.

Posted on 2001-07-23
4
282 Views
Last Modified: 2012-08-14
How to close popup window if opener window closed.

Regards,
Hamid
0
Comment
Question by:HamidHossain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 15

Expert Comment

by:a.marsh
ID: 6308338
Assuming you have stored a reference to the child window in a variable called "winref" then in the opener window use this:

<body onunload="if(winref != null && !winref.closed){ winref.close(); }">


Ant
0
 
LVL 9

Accepted Solution

by:
nimaig earned 30 total points
ID: 6308344
While opening the child window you need to keep track of the reference of the Child Window
eg.

var childWin;

function openWin(){
     childWin = window.open("test.html","","");
}

If you have the reference then on unload event of the body, you can close the window

eg.
function CloseChildWindow(){
     if(childWin)
          childWin.close();
}


Calling the function :
<body onUnLoad="CloseChildWindow()">
0
 
LVL 1

Expert Comment

by:Y_ee
ID: 6310118
a.marsh  !!

this is funny you are all over I guess I apologies here too

ciao
Y
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 7152101
________________________________________
do not accept this comment as the answer

this question has been abandoned. experts please
post recommendations below to help the moderators.



________________________________________
my recommendation
split.
a.marsh
nimaig
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…
Suggested Courses

732 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