Alert box then close window

Discussion in 'Javascript' started by BWGames, May 3, 2004.

  1. BWGames

    BWGames Guest

    Hi,

    I'm looking for a way to have a message box pop up as a page is
    loaded, then, when the user clicks OK on the message box, for the
    window to close.

    It will be a popup window, so there won't be any "This webpage is
    trying to close this window" errors...

    Anyone help me out?

    Thanks,

    Ben
     
    BWGames, May 3, 2004
    #1
    1. Advertising

  2. BWGames

    Evertjan. Guest

    BWGames wrote on 03 mei 2004 in comp.lang.javascript:

    > I'm looking for a way to have a message box pop up as a page is
    > loaded, then, when the user clicks OK on the message box, for the
    > window to close.
    >
    > It will be a popup window, so there won't be any "This webpage is
    > trying to close this window" errors...
    >


    <script type="text/javascript">
    alert("Please click OK to close window");
    window.close();
    </script>

    IE6 tested

    = or nicer ============

    <body onclick="window.close();"
    onload="window.resizeTo(300,200);">
    Please click this window anywhere to close
    </body>

    IE6 tested

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., May 3, 2004
    #2
    1. Advertising

  3. BWGames wrote:

    > I'm looking for a way to have a message box pop up as a page is
    > loaded, then, when the user clicks OK on the message box, for the
    > window to close.
    >
    > It will be a popup window, so there won't be any "This webpage is
    > trying to close this window" errors...


    It does not make sense to me to open a window just to get it closed.
    FWIW:

    if (window.confirm("Close window now?"))
    {
    window.close();
    }

    RTFM.


    PointedEars
     
    Thomas 'PointedEars' Lahn, May 24, 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. Ganesh
    Replies:
    0
    Views:
    562
    Ganesh
    Jun 29, 2007
  2. Kuldeep

    Show Alert Box and then Redirect

    Kuldeep, Oct 31, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    21,508
    sun_kkd
    Apr 27, 2012
  3. Replies:
    0
    Views:
    304
  4. Iñaki Baz Castillo
    Replies:
    7
    Views:
    879
    Iñaki Baz Castillo
    Jan 12, 2010
  5. Shang Wenbin

    close current window using window.close()

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

Share This Page