RE: window closing

by "Brett Errington" <brett(at)opensearch.com>

 Date:  Sat, 11 May 2002 13:39:37 +0800
 To:  <hwg-techniques(at)hwg.org>
 In-Reply-To:  peel3
  todo: View Thread, Original
You have to assign the window to a variable. That way you have an object
reference (the window) rather than just a title. You need to simple put
the variable equals in front of your window.open method... i.e:

function openit(){
MyWindow = window.open("test1.html","mywindow","width=400,height=500");
}

the in your close function rather than close("MyWindow") you should use
MyWindow.close();

Hope this helps.

Later,
Mr Brett
 
"That's a pain that will surely linger, and that's no lie"
- Ed Grimely
-----Original Message-----
From: owner-hwg-techniques(at)hwg.org [mailto:owner-hwg-techniques(at)hwg.org]
On Behalf Of Nate Harel
Sent: Saturday, 11 May 2002 7:50 AM
To: jim barchuk; hwg-techniques(at)hwg.org
Subject: Re: window closing

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




> Hi Nate!
> 
> > Using Javascript, open a new window (call it "New") by clicking on 
one
> > link, and then closing "New" by clicking on another link.
> >
> > The problem I have been running into is that I get prompted with the
> > question "The web page you are viewing is trying to close the 
window. Do
> > you want to close it?"
> 
> A 'problem,' eh?
> 
> > I thought that if a particular window opens another, it also has the
> > "right" to close it.
> 
> A 'right,' eh? How well do those shoes fit on your feet? How would you
> feel if simply clicking a link closed *YOUR* window?
> 
> There used to be a JS obnoxiousness that would fully -shut- -down- Win
> 3.1. That went away pretty quick. :)
> 
> But that's why I browse with JS disabled anyway just in case some
> foolishness like that arises again.
> 
> Have a :) day!
> 
> jb
> 
> -- 
> jim barchuk
> jb(at)jbarchuk.com
> 
> 
> 


======================
Nate Harel
NetTech Services Corp
56 Pickering Street
Needham, MA  02492
781-559-8176
www.nettech-services.com

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