Google Answers Logo
View Question
 
Q: JavaScript: Closing Child Window from Parent ( No Answer,   1 Comment )
Question  
Subject: JavaScript: Closing Child Window from Parent
Category: Computers
Asked by: kismetquery-ga
List Price: $10.00
Posted: 06 Feb 2006 08:02 PST
Expires: 08 Mar 2006 08:02 PST
Question ID: 442113
We have a browser window which displays a menu in the main page and on
user's selection pops up another browser window with some DHTML
content.

On the parent window the user has hyperlinks for sign-out. 

We need to:
1. Request the user to confirm whether he really wants to signout (or
close the parent window, if he clicks on browser close (X) button).

2. Close the child popup window if the parent window is closed or user
selects the Sign-Out.

3. Get to know what the user clicked to close the parent window.

Please note we have a menu in the main page, so the user can navigate
away from the page where the child browser window was popped up from
initially. We should be able to close the child window even from a
page (in the parent window) which did not open it.


Here is the code that we have already tried:
***************************************************************
<script language=javascript>
function unLoadFncIE(evt){
 var e = (window.event) ? window.event : evt;  if(e.clientY<0){return
"Closing this window will close the child window too.";} }

var childWnd ;
function closeDep() {
      if (childWnd && childWnd.open && !childWnd.closed)
childWnd.close(); } function openWindow(){
         childWnd = window.open("./childwindow.htm", "ChildWind", ""); } </script>

<body onbeforeunload="return unLoadFncIE(event);" onunload="return
unLoadFullyFncIE();">
***************************************************************


But this works only from the page that opened the child window.


Thanks,
Regards,

K. Dev

Clarification of Question by kismetquery-ga on 06 Feb 2006 22:24 PST
function unLoadFullyFncIE(){
var e = (window.event) ? window.event : evt;
 if(e.clientY<0){ 
   closeDep();
  }
}
Answer  
There is no answer at this time.

Comments  
Subject: Re: JavaScript: Closing Child Window from Parent
From: gauravtripathi-ga on 09 Feb 2006 23:10 PST
 
Try out with following steps:
1. Include following script tag in all your parent(HTML) pages
 <script language=javascript>
   var childWnd;
 </script> 

2. Now call your existing function from parent classes 
closeDep()

I think this will work.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy