How to close all windows in a web application?

Discussion in 'ASP .Net' started by =?Utf-8?B?UGF1bA==?=, Nov 22, 2004.

  1. 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.
    =?Utf-8?B?UGF1bA==?=, Nov 22, 2004
    #1
    1. Advertising

  2. 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" <> ¦b¶l¥ó
    news: ¤¤¼¶¼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.
    Lau Lei Cheong, Nov 23, 2004
    #2
    1. Advertising

  3. 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" <> ¦b¶l¥ó
    > news: ¤¤¼¶¼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.

    >
    >
    >
    =?Utf-8?B?UGF1bA==?=, Nov 23, 2004
    #3
  4. =?Utf-8?B?UGF1bA==?=

    Vik Guest

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

    Thanks.

    "Lau Lei Cheong" <> wrote in message
    news:...
    > 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" <> ¦b¶l¥ó
    > news: ¤¤¼¶¼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.

    >
    >
    Vik, Nov 23, 2004
    #4
  5. 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" <> wrote in message
    > news:...
    > > 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" <> ¦b¶l¥ó
    > > news: ¤¤¼¶¼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.

    > >
    > >

    >
    >
    >
    =?Utf-8?B?UGF1bA==?=, Nov 23, 2004
    #5
  6. 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" <> ¦b¶l¥ó
    news: ¤¤¼¶¼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" <> |b?l¢Do
    > > news: ?????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.

    > >
    > >
    > >
    Lau Lei Cheong, Nov 24, 2004
    #6
  7. =?Utf-8?B?UGF1bA==?=

    Vik Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > > news:...
    > > > 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" <> bl?o
    > > > news: ????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.
    > > >
    > > >

    > >
    > >
    > >
    Vik, Nov 24, 2004
    #7
  8. 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==> ¦b¶l¥ó
    news: ¤¤¼¶¼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" <> wrote in message
    > news:...
    > > 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" <> wrote in message
    > > > news:...
    > > > > 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" <> bl?o
    > > > > news: ????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.
    > > > >
    > > > >
    > > >
    > > >
    > > >

    >
    >
    Lau Lei Cheong, Nov 25, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RJN
    Replies:
    2
    Views:
    4,885
  2. Replies:
    6
    Views:
    8,802
    sateeshranga
    Aug 7, 2008
  3. Dani
    Replies:
    3
    Views:
    468
  4. Iñaki Baz Castillo
    Replies:
    7
    Views:
    821
    Iñaki Baz Castillo
    Jan 12, 2010
  5. Replies:
    3
    Views:
    392
    Chung Leong
    Jan 16, 2005
Loading...

Share This Page