By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,782 Members | 1,154 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,782 IT Pros & Developers. It's quick & easy.

How to close all windows in a web application?

P: n/a
Hi I have a web application that has a log off selection, just redirects the
browser to a form with a label displaying you are loging off. In part of the
application I open a new window and was wondering if there is a way to close
all windows associated with the web application when the user selects the log
off selection?
Thanks.
--
Paul G
Software engineer.
Nov 18 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Just create an array of variable that holds the handle returned by your
calls to window.open(). Then use it to close accordingly.

e.g.:
function openwin() {
fhandle = window.open("popup.aspx");
}

function closewin() {
fhandle.close();
}

"Paul" <Pa**@discussions.microsoft.com> bl
news:C9**********************************@microsof t.com g...
Hi I have a web application that has a log off selection, just redirects the browser to a form with a label displaying you are loging off. In part of the application I open a new window and was wondering if there is a way to close all windows associated with the web application when the user selects the log off selection?
Thanks.
--
Paul G
Software engineer.

Nov 18 '05 #2

P: n/a
Thanks for the information, just wondering if you know what event to use if
aparent different aspx file is loaded into the web window, say with a
hyperlink as I want to close another window when this takes place?

"Lau Lei Cheong" wrote:
Just create an array of variable that holds the handle returned by your
calls to window.open(). Then use it to close accordingly.

e.g.:
function openwin() {
fhandle = window.open("popup.aspx");
}

function closewin() {
fhandle.close();
}

"Paul" <Pa**@discussions.microsoft.com> ¦b¶l¥ó
news:C9**********************************@microsof t.com ¤¤¼¶¼g...
Hi I have a web application that has a log off selection, just redirects

the
browser to a form with a label displaying you are loging off. In part of

the
application I open a new window and was wondering if there is a way to

close
all windows associated with the web application when the user selects the

log
off selection?
Thanks.
--
Paul G
Software engineer.


Nov 18 '05 #3

P: n/a
Vik
How can I get a handle of a browser window which is opened by a user through
the browser menu?

Thanks.

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
Just create an array of variable that holds the handle returned by your
calls to window.open(). Then use it to close accordingly.

e.g.:
function openwin() {
fhandle = window.open("popup.aspx");
}

function closewin() {
fhandle.close();
}

"Paul" <Pa**@discussions.microsoft.com> bl
news:C9**********************************@microsof t.com g...
Hi I have a web application that has a log off selection, just redirects the
browser to a form with a label displaying you are loging off. In part

of the
application I open a new window and was wondering if there is a way to close
all windows associated with the web application when the user selects

the log
off selection?
Thanks.
--
Paul G
Software engineer.


Nov 18 '05 #4

P: n/a
I set up this below as lau suggested, and it the functions seem to work. So
the handle for the window that displays control_numifno.aspx is win_usr.
<script language="javascript">
function openwin(){
win_usr=window.open ("control_numinfo.aspx")
}
function closewin(){
win_usr.close();
}

"Vik" wrote:
How can I get a handle of a browser window which is opened by a user through
the browser menu?

Thanks.

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
Just create an array of variable that holds the handle returned by your
calls to window.open(). Then use it to close accordingly.

e.g.:
function openwin() {
fhandle = window.open("popup.aspx");
}

function closewin() {
fhandle.close();
}

"Paul" <Pa**@discussions.microsoft.com> ¦b¶l¥ó
news:C9**********************************@microsof t.com ¤¤¼¶¼g...
Hi I have a web application that has a log off selection, just redirects

the
browser to a form with a label displaying you are loging off. In part

of
the
application I open a new window and was wondering if there is a way to

close
all windows associated with the web application when the user selects

the
log
off selection?
Thanks.
--
Paul G
Software engineer.



Nov 18 '05 #5

P: n/a
There are many ways. But the following is the one I preferred.

Add another server-side hidden textbox named "hid_func". The script for
opening window should set it to "hwndsav" then call click() on a server-side
button. When the server-side button handler see hid_func.Text == "hwndsav",
it knows it should save the handle and then set it's value to "" again. In
this fashion you can implement other client-server side interaction using
this single button.

"Paul" <Pa**@discussions.microsoft.com> bl
news:45**********************************@microsof t.com g...
Thanks for the information, just wondering if you know what event to use if aparent different aspx file is loaded into the web window, say with a
hyperlink as I want to close another window when this takes place?

"Lau Lei Cheong" wrote:
Just create an array of variable that holds the handle returned by your
calls to window.open(). Then use it to close accordingly.

e.g.:
function openwin() {
fhandle = window.open("popup.aspx");
}

function closewin() {
fhandle.close();
}

"Paul" <Pa**@discussions.microsoft.com> |b?lDo
news:C9**********************************@microsof t.com ?????g...
Hi I have a web application that has a log off selection, just
redirects the
browser to a form with a label displaying you are loging off. In part
of the
application I open a new window and was wondering if there is a way to

close
all windows associated with the web application when the user selects
the log
off selection?
Thanks.
--
Paul G
Software engineer.


Nov 18 '05 #6

P: n/a
Vik
In your example, the new window is open by code. What I need to know is a
handle for the new window opened by a user through the browser menu
File->New->Window.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
I set up this below as lau suggested, and it the functions seem to work. So the handle for the window that displays control_numifno.aspx is win_usr.
<script language="javascript">
function openwin(){
win_usr=window.open ("control_numinfo.aspx")
}
function closewin(){
win_usr.close();
}

"Vik" wrote:
How can I get a handle of a browser window which is opened by a user through the browser menu?

Thanks.

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
Just create an array of variable that holds the handle returned by your calls to window.open(). Then use it to close accordingly.

e.g.:
function openwin() {
fhandle = window.open("popup.aspx");
}

function closewin() {
fhandle.close();
}

"Paul" <Pa**@discussions.microsoft.com> bl?o
news:C9**********************************@microsof t.com ????g...
> Hi I have a web application that has a log off selection, just redirects the
> browser to a form with a label displaying you are loging off. In part
of
the
> application I open a new window and was wondering if there is a way
to close
> all windows associated with the web application when the user

selects the
log
> off selection?
> Thanks.
> --
> Paul G
> Software engineer.


Nov 18 '05 #7

P: n/a
The fact is: You simply can't alter things that is not within your current
scope of DOM model.

Since the window opened using "File"->"New"->"Window" is not opened by your
script, you has no reference/handle/access to it and cannot close it. By
enabling the script to do so is in fact violating the security measure of
the browser. (Since maybe one window is opening pages in internet zone and
another is opening pages in local zone, if I can manipulate other window
then maybe I'm possible to execute malicious ActiveX controls on the client.
The best way to prevent this is to block access from your script to it.)

For example, you're assured when you checking your email through webmail,
the other pages you're visiting cannot see the content of your email. (Or is
it so? Maybe someone have trick to get through it. Also, I can't remember
whether cookies can be shared over windows opened by this method.)

"Vik" <viktorum@==hotmail.com==> bl
news:eZ**************@TK2MSFTNGP10.phx.gbl g...
In your example, the new window is open by code. What I need to know is a
handle for the new window opened by a user through the browser menu
File->New->Window.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
I set up this below as lau suggested, and it the functions seem to work. So
the handle for the window that displays control_numifno.aspx is win_usr.
<script language="javascript">
function openwin(){
win_usr=window.open ("control_numinfo.aspx")
}
function closewin(){
win_usr.close();
}

"Vik" wrote:
How can I get a handle of a browser window which is opened by a user through the browser menu?

Thanks.

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
> Just create an array of variable that holds the handle returned by your > calls to window.open(). Then use it to close accordingly.
>
> e.g.:
> function openwin() {
> fhandle = window.open("popup.aspx");
> }
>
> function closewin() {
> fhandle.close();
> }
>
> "Paul" <Pa**@discussions.microsoft.com> bl?o
> news:C9**********************************@microsof t.com ????g...
> > Hi I have a web application that has a log off selection, just redirects > the
> > browser to a form with a label displaying you are loging off. In part of
> the
> > application I open a new window and was wondering if there is a
way to > close
> > all windows associated with the web application when the user selects the
> log
> > off selection?
> > Thanks.
> > --
> > Paul G
> > Software engineer.
>
>


Nov 18 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.