[thelist] Quick JS question

Warden, Matt mwarden at odyssey-design.com
Mon Mar 19 16:51:46 CST 2001


> Here's a way to do this:
>
> parent.htm:
> <a href="#" onClick="window.open('child.htm', 'child');">child</a>
>
> child.htm:
> <a href="#" onClick="opener.location.href='http://www.foo.com';
> self.close()">foo</a>

I did a quick test and this pukes if the parent has been closed. You just have
to check if window.opener exists before you access its properties:


if (window.opener)
{
    opener.location.href='http://www.foo.com';
}
else
{
    window.open(...);
}

Other than that, you're idea works great.


Thanks,


--
mattwarden
mattwarden.com





More information about the thelist mailing list