Entry
how to close child window when parent page is redirect
Apr 8th, 2008 17:59
ha mo, Keyar Srinivasan, John Cherian, http://keyarsrinivasan.blogspot.com
The dependent window feature specifies whether the window should be a
dependent child of the current (opener) window. A dependent window
closes when its parent window closes. This dependent feature is only
supported by Navigator 4 and above. However, we can use a bit of
JavaScript to deliver a cross-browser solution. Let's use the following
function to open our dependent window:
function openDep() {
win = window.open("depwin.html", "dep", "height=200,width=400");
}
We'll include an onUnload event handler to close the dependent window
when the current window closes or a new URL is loaded:
<BODY onUnload="closeDep()">
Note that the new window will close when the current document unloads,
even if the current window is still open. Here's the code for the
closeDep() function:
function closeDep() {
if (win && win.open && !win.closed) win.close();
}
Notice that we must check if the window exists before we attempt to
close it. To learn more, have a look at a complete demonstration in
http://www.webreference.com/js/tutorial1/reference.html
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com