Click here to Skip to main content
13,050,358 members (139,346 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 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.
Posted 20-Jun-12 3:22am
Sergey Alexandrovich Kryukov 20-Jun-12 18:50pm
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 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
Please Sign up or sign in to vote.

Solution 1

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

var windowToClose ="test.htm");
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.
Rate this: bad
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. :-)


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 20 Jun 2012
Copyright © CodeProject, 1999-2017
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