Close a popup window

Discussion in 'ASP .Net' started by David W. Simmonds, Feb 15, 2004.

  1. I have a popup window appear when a user clicks on a hyperlink in a
    datalist. I do it like this:

    dr[8] = "javascript:mywindow=window.open(" +
    "\"GameStats.aspx?Date="+dr[0] + "&Away="+dr[1] + "&Home="+dr[4] + "\"" +
    ",\"GamesStats\",\"toolbar=no,location=no,directories=no,menubar=no,resizabl
    e=yes,scrollbars=yes,width=640,height=300\");mywindow.focus();";

    dr[8] is a DataRow item that is added to a DataTable that becomes the
    DataSource of the DataGrid.

    Is there a way to have that window close when the form that caused it to
    appear closes?
     
    David W. Simmonds, Feb 15, 2004
    #1
    1. Advertising

  2. David W. Simmonds

    Dan Brussee Guest

    Using the onunload event of the window object.

    window.onunload = ClosePop;
    function ClosePop() {
    if (mywindow != null) {
    if (mywindow != "undefined") {
    mywindow.close();
    }
    }
    }

    Also, before popping up your window, call ClosePop(). This will assure
    that you only have one popup open... assuming you always call your
    popup mywindow.


    On Sun, 15 Feb 2004 16:03:53 GMT, "David W. Simmonds"
    <> wrote:

    >I have a popup window appear when a user clicks on a hyperlink in a
    >datalist. I do it like this:
    >
    >dr[8] = "javascript:mywindow=window.open(" +
    >"\"GameStats.aspx?Date="+dr[0] + "&Away="+dr[1] + "&Home="+dr[4] + "\"" +
    >",\"GamesStats\",\"toolbar=no,location=no,directories=no,menubar=no,resizabl
    >e=yes,scrollbars=yes,width=640,height=300\");mywindow.focus();";
    >
    >dr[8] is a DataRow item that is added to a DataTable that becomes the
    >DataSource of the DataGrid.
    >
    >Is there a way to have that window close when the form that caused it to
    >appear closes?
    >
     
    Dan Brussee, Feb 15, 2004
    #2
    1. Advertising

  3. That works great! Thanks.

    "Dan Brussee" <> wrote in message
    news:...
    > Using the onunload event of the window object.
    >
    > window.onunload = ClosePop;
    > function ClosePop() {
    > if (mywindow != null) {
    > if (mywindow != "undefined") {
    > mywindow.close();
    > }
    > }
    > }
    >
    > Also, before popping up your window, call ClosePop(). This will assure
    > that you only have one popup open... assuming you always call your
    > popup mywindow.
    >
    >
    > On Sun, 15 Feb 2004 16:03:53 GMT, "David W. Simmonds"
    > <> wrote:
    >
    > >I have a popup window appear when a user clicks on a hyperlink in a
    > >datalist. I do it like this:
    > >
    > >dr[8] = "javascript:mywindow=window.open(" +
    > >"\"GameStats.aspx?Date="+dr[0] + "&Away="+dr[1] + "&Home="+dr[4] + "\"" +

    >
    >",\"GamesStats\",\"toolbar=no,location=no,directories=no,menubar=no,resizab

    l
    > >e=yes,scrollbars=yes,width=640,height=300\");mywindow.focus();";
    > >
    > >dr[8] is a DataRow item that is added to a DataTable that becomes the
    > >DataSource of the DataGrid.
    > >
    > >Is there a way to have that window close when the form that caused it to
    > >appear closes?
    > >

    >
     
    David W. Simmonds, Feb 15, 2004
    #3
    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. Matt Jensen
    Replies:
    1
    Views:
    5,273
    Matt Jensen
    Dec 16, 2005
  2. Iñaki Baz Castillo
    Replies:
    7
    Views:
    949
    Iñaki Baz Castillo
    Jan 12, 2010
  3. Jens Peter Hansen
    Replies:
    7
    Views:
    594
    Randy Webb
    Jun 19, 2004
  4. Raffi
    Replies:
    4
    Views:
    263
    Dr John Stockton
    Aug 12, 2004
  5. Shang Wenbin

    close current window using window.close()

    Shang Wenbin, Sep 1, 2005, in forum: Javascript
    Replies:
    10
    Views:
    426
    Gérard Talbot
    Sep 2, 2005
Loading...

Share This Page