f



Window.close() 207265

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
0
jhe_bc
6/28/2003 7:50:39 PM
comp.lang.javascript 38370 articles. 2 followers. javascript4 (1315) is leader. Post Follow

1 Replies
762 Views

Similar Articles

[PageSpeed] 25

John H. wrote:
> 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");
>                      ... 
>       }
> 

You must make the window object reference as a global variable, 
otherwise you won't be able to reference it from outside its function 
for blur(), focus(), closed and close() methods and properties.

You must remove blank space between the windowFeatures string list in 
the 3rd argument, otherwise such windowFeature requests won't be honored 
in NS.
"windowFeatures is an optional string containing a comma-separated list 
of options for the new window (do not include any spaces in this list)."
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1202731 


Note here that either way, you are removing basic normal browser window 
functionalities (resizability and scrollbars presence if needed, that is 
if content overflows window dimensions) from your popup which is 
definitively not recommendable (accessibility to content and usability).
You can not force the statusbar to be hidden for NS 6+ and Mozilla-based 
browsers users.


> ASP.net will automatically call BasicSearchValidation and open a
> window,
>  but when I click close button on the window

On which window exactly? window.close(), self.close(), w1.close() are 3 
different calls depending on where you make such call. Here, in your 
code, we have no clues at all on how and where you may be making which call.

, it always prompt a
> messagebox to ask me to close it. How can I close the window without
> the prompting the messagebox?
> 
> Thanks!
> 
> 
> John

Check the FAQ on this.
http://jibbering.com/faq/
A window not opened by javascript can NOT be closed by javascript 
because it can not be referenced with client-side javascript.

DU
---------------------------
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

0
DU
6/28/2003 9:01:28 PM
Reply: