You are here: irt.org | FAQ | JavaScript | Window | Q1807 [ previous next ]
A spawned child window contains a link that is supposed to open in the parent, then the child is supposed to close. This is similar to the Javascript:Windows FAQ 84, yet decidedly different.
A simple onclick="window.close" won't work in this case because the window will close before it has a chance to process the link. So, use the code for FAQ 84 and attach a window.close to the end. This forces the child to think about what he's done and process the link before closing.
<head>: <script language="JavaScript"><!-- function load(file,target) { if (target != '') { target.window.location.href = file; } else { window.location.href = file; } window.close(); } //--></script> The link: <a href="javascript:load('thelink.html',opener)">
Submitted by Dan