Click here to Skip to main content
15,907,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all ,

I have a web application. In that through javascript I have opened a popup window from my application.Once I close my application, the popup window which is opened through javascript method is not getting closed.
This is my javascript
function show() {
                 myRef = window.open('http://www.google.com, 'mywin',
'left=20,top=20,width=700,height=600,toolbar=1,resizable=1');
}


How to close this popup when application is closed?

Can anyone help on this issue ?

Thanks in advance,

Naveen
Posted
Updated 1-Nov-10 2:40am
v2

Hi Naveen,

You can do using maintain all window in list.

Somewhere at the top of your script in your main document you include a
line:
C#
var children=Array();


Now whenever you want to open a new child window make sure you use a line similar to:
C#
children[children.length]= name of the window;


You can then have one function such as:
C#
function closeAllChildren()
{
   for(var n=0;n<children.length;n++)
   {
       children[n].close();
   }
   //Oh, and close self!
   window.close();
}


Each child document just needs a button to call this function as follows.
C#
<input type="button" onclick="window.opener.closeAllChildren()">



Please do let me know, if you have any doubt.

Please provide "Vote":thumbsup: if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Thanks,
Imdadhusen
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900