Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 20-Jun-12 4:22am
Comments
Sergey Alexandrovich Kryukov at 20-Jun-12 18:50pm
   
Why?!!
--SA
Manisha Tambade at 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.
 
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

When you open a window using window.open it returns a handle to that window. You can close it with that:
 
var windowToClose = window.open("test.htm");
windowToClose.close();
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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. Smile | :)
 
—SA
  Permalink  
v2

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



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 20 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100