Re: Javascript Question

by Nathan Lyle <natelyle(at)>

 Date:  Thu, 6 Dec 2001 21:41:52 -0500
 To:  Ben Ocean <lists(at)>
 Cc:  hwg-techniques(at)
 References:  thewebsons
  todo: View Thread, Original
> I have a window that opens a child window via a Javascript. There is a link
> in said child that I would like to redirect the parent onUnload (and close 
> of said child). Unfortunately, parent.location doesn't work since that 
> simply references the child. What do?

Pass a reference of the parent to the child. Following is a snippet
from one of my efforts. Hope it helps. :)

In the head:

function showAnswer(self_reference) {
nw ="","","");
if (!nw.opener) nw.opener = self;
  with (nw.document) {
    writeln("<body bgcolor=#ffffff>");
    writeln("<a href=\"javascript:this.close();\"onClick=\"" +
self_reference + ".location.href=\'\';\">LINKTEXT</a>");
  writeln("<a href=\"javascript:this.close();\">CLOSE</a></div>");

Somewhere in the body of the main window (this would open the child):

<a href="javascript:showAnswer(" + x + ",'opener.document');\"></a>

~Nathan Lyle   (The Tragic Comedian Poet)

Email: natelyle(at)
Phone: (906)485-4806

"Tragedy is if I cut my finger, comedy is if I walk into an open sewer and die." - Mel Brooks

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