Solved

Close popup window if opener window closed.

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

Regards,
Hamid
0
Comment
Question by:HamidHossain
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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 …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

831 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