Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,
in my web application i have opened my main default on browser tab and as i opens links from linkbuttons then i opens new windows using javascript window.open function.

now i want to close all windows programatically,is there any way to achieve this.
i tried many ways.

If anybody knows then pls help.
Thanks.
Posted
Comments
Sergey Alexandrovich Kryukov 20-Jun-12 18:50pm    
Why?!!
--SA
Manisha Tambade 23-Jun-12 1:37am    
thanks for reply.
Actually on logout link of main page i want to close all opened windows and redirect user to default page,So i need to do this.
I opens all child windows on same parent window using window.open() but when i refresh parrent programatically my child window objects getting null(Array becomes reset) so i not able to close child windows.


When you open a window using window.open it returns a handle to that window. You can close it with that:

JavaScript
var windowToClose = window.open("test.htm");
windowToClose.close();
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Jun-12 18:49pm    
First, "all windows programmatically" means on some event which shared by all windows. Where do you want to store this information about all those windows? (You can, I know. But you did not explain that.)

But main thing is: can we give such advice at all? Main problem is: this "requirement" is a disaster. It's much more important to warn OP against it. It really never should be done. -- Please see my answer.
--SA
If you want to close all windows programmatically, you abuse your user. It's the user's prerogative to decide what to close and what not. You can offer something like a "Close" button or something like that, no more. However, if you really want the user to remember your Web site as "never visit again", go ahead. :-)

—SA
 
Share this answer
 
v2

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