Close window with JavaScript

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Close window with JavaScript

    Hello

    I have some trouble in closing a window, Here is the problem:

    I develop a asp.net website use client side valiation

    <asp:CustomValidator id="CustomValidator1"
    ControlToValidate="Text1"
    ClientValidationFunction="BasicSearchValidation"
    OnServerValidate="ServerValidation"
    Display="Static"
    ErrorMessage="Not an even number!"
    ForeColor="green"
    Font-Name="verdana"
    Font-Size="10pt"
    runat="server"/>


    the validation function (JavaScript) is

    BasicSearchValidation(source, arguments)
    {
    ...

    w1 = window.open("PopupErrorMsg.htm", "example1", "width=400,
    height=300, location=no, menubar=no, status=no, toolbar=no,
    scrollbars=no, resizable=no");
    ...
    }

    ASP.net will automatically call BasicSearchValidation and open a
    window,
    but when I click close button on the window, it always prompt a
    messagebox to ask me to close it. How can I close the window without
    the prompting the messagebox?

    Thanks!


    John
    John H. Guest

  2. Similar Questions and Discussions

    1. Close Window JavaScript CS3
      Does anyone know how to close a pop-up window in Dreamweaver CS3? I have upgraded from GoLive 6.01 and it was easy there! Thanks in advance
    2. close my project that is in a browser window (close this window)
      How can I do this with a button? What do I have to put into button?
    3. MIAW forget window vs. close window
      I'm having a problem with forget window. Sometimes when I forget a window, the projector crashes. The problem sometimes happens the first time I...
    4. how to close a javascript window when asp script end
      i open the file download.asp from another main.asp page using window.open what the problem is when i clikc on the hyperlink it prompts me the ie...
    5. window sizing & close this window code
      Sharon wrote on 16 jul 2003 in microsoft.public.inetserver.asp.general: No ASP to be seen, Sharon, please see a clientside NG, --...
  3. #2

    Default Re: Close window with JavaScript

    Hi

    If your app did not open the window ( window.open ) you will get a confirm
    box
    [url]http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/close_0.asp[/url]

    There is a hack but I don't think its a good idea using it so I wont post it
    :)

    --
    Best Regards
    Vidar Petursson
    ==============================
    Microsoft Internet Client & Controls MVP
    ==============================
    "John H." <jhe_bc@yahoo.ca> wrote in message
    news:5112cc93.0306281152.3c12ad49@posting.google.c om...
    > Hello
    >
    > I have some trouble in closing a window, Here is the problem:
    >
    > I develop a asp.net website use client side valiation
    >
    > <asp:CustomValidator id="CustomValidator1"
    > ControlToValidate="Text1"
    > ClientValidationFunction="BasicSearchValidation"
    > OnServerValidate="ServerValidation"
    > Display="Static"
    > ErrorMessage="Not an even number!"
    > ForeColor="green"
    > Font-Name="verdana"
    > Font-Size="10pt"
    > runat="server"/>
    >
    >
    > the validation function (JavaScript) is
    >
    > BasicSearchValidation(source, arguments)
    > {
    > ...
    >
    > w1 = window.open("PopupErrorMsg.htm", "example1", "width=400,
    > height=300, location=no, menubar=no, status=no, toolbar=no,
    > scrollbars=no, resizable=no");
    > ...
    > }
    >
    > ASP.net will automatically call BasicSearchValidation and open a
    > window,
    > but when I click close button on the window, it always prompt a
    > messagebox to ask me to close it. How can I close the window without
    > the prompting the messagebox?
    >
    > Thanks!
    >
    >
    > John

    Vidar Petursson Guest

  4. #3

    Default Re: Close window with JavaScript

    window.opener = self;
    window.close();

    HTH,

    Kevin Spencer
    Microsoft FrontPage MVP
    Internet Developer
    [url]http://www.takempis.com[/url]
    Big things are made up of
    lots of Little things.

    "John H." <jhe_bc@yahoo.ca> wrote in message
    news:5112cc93.0306281152.3c12ad49@posting.google.c om...
    > Hello
    >
    > I have some trouble in closing a window, Here is the problem:
    >
    > I develop a asp.net website use client side valiation
    >
    > <asp:CustomValidator id="CustomValidator1"
    > ControlToValidate="Text1"
    > ClientValidationFunction="BasicSearchValidation"
    > OnServerValidate="ServerValidation"
    > Display="Static"
    > ErrorMessage="Not an even number!"
    > ForeColor="green"
    > Font-Name="verdana"
    > Font-Size="10pt"
    > runat="server"/>
    >
    >
    > the validation function (JavaScript) is
    >
    > BasicSearchValidation(source, arguments)
    > {
    > ...
    >
    > w1 = window.open("PopupErrorMsg.htm", "example1", "width=400,
    > height=300, location=no, menubar=no, status=no, toolbar=no,
    > scrollbars=no, resizable=no");
    > ...
    > }
    >
    > ASP.net will automatically call BasicSearchValidation and open a
    > window,
    > but when I click close button on the window, it always prompt a
    > messagebox to ask me to close it. How can I close the window without
    > the prompting the messagebox?
    >
    > Thanks!
    >
    >
    > John

    Kevin Spencer Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139