FIXED Re: [thelist] javascript: closing a window opened from a previous page

Scott Dexter dexilalolai at
Fri Apr 30 09:43:40 CDT 2004

> How about the opened window closing itself, when its 
> window.opener.location== B?

Good idea. This is what I ended up coming up with, and it will work
for my use. An interesting thing I found out here was the
may or may NOT change depending on how the form is submitted.
Submitting the form through the javascript call below
(theform.submit()) works regardless of the form method (POST or GET).
IF you submit with the <form> tag, using GET doesn't change the attribute; in fact, it gets the name of the page being
submitted TO. Interesting. But I gots it working, and code is below
for your entertainment. I feel meek that it took me this long, but

<script language="javascript"> = 'pageA.htm';

function doSubmit(){
// open a child window, and it will close itself
var newWin ='child.htm','child','scrollbars=no,resizable=yes,dependent=no,height=500,width=620');


<script language="javascript"> = 'pageB.asp';


<script language="JavaScript">
var origOpener = window.opener;
var origName =;

function OpenerWatch(){
// watch for changes in the
} //end OpenerWatch

function testOpener(strName){
// if the opener reference is lost, close this window
if (opener &&!=strName) {
	alert('Closing -- the opener page changed: \n original name: ' +
strName + '\n name now: ' +;
} else {
	alert('Opener still there -- ' +;
}// end testOpener
<body onLoad="OpenerWatch()">


Thanks for listening,

More information about the thelist mailing list