Re: window closing

by "Michael Gerholdt" <gerholdt(at)fredonia.edu>

 Date:  Fri, 10 May 2002 22:20:02 -0400
 To:  <nharel(at)nettech-services.com>,
"jim barchuk" <jb(at)jbarchuk.com>,
<hwg-techniques(at)hwg.org>
 References:  peel3
  todo: View Thread, Original
1) I believe that the asking permission is a browser configuration issue.
Javascript can close the window, but browser security is set to prompt you.
Mine used to but does no longer. Unfortunately, I don't recall what caused
the behavior change.

2) If you have a link in window A that is to close window b, you have to
specify which window to close, else the script assumes that you intend it to
close the window the script is in. It is more usual to close a window from
within the window, as your script does. You'll need to modify the function
to receive window name as a parameter and close that window.

hth

Mike

> According to the javascript book (O'Reilly)
> "Only windows opened by Javascript can be closed by Javascript..."
>
> That's what I want to do.
>
> The code I am using is
> ----------------------
> <script language="JavaScript1.2">
> <!--
>
> function openit(){
> window.open("test1.html","mywindow","width=400,height=500")
> }
>
> function closeit(){
>  close("mywindow");
> }
>
> //-->
> </script>
>
> <A href="#" onClick="openit()">This is the link to open another
> window.</A>
>
> <A href="#" onClick="closeit()">This is the link to close that
> window</A>
>
> ------------------
>
> The bottom link first asks me for permission and then closes itself
> rather than "mywindow". How do I get it close "mywindow".
>
> Nate

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA