Solved

Close popup window if opener window closed.

Posted on 2001-07-23
4
280 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

829 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