I want the code so that the chilld window closes as soon as the parent window is closed in asp.net.?
How can this be achieved?
I want the code so that the chilld window closes as soon as the parent window is closed in asp.net.?
How can this be achieved?
Too bad that "dependent" no longer works. As Redlab commented, you need to keep track. Some browsers will not execute script that is called from the unload event, but try this
<script type="text/javascript">
var childWin = [];
function openWin(link) {
var childWin[childWin.length] = window.open(link.href,link.target,'dependent');
return childWin[childWin.length-1]?false:true; // if popup blocker
}
function closeWin() {
for (var i=0;i<childWin.length;i++) {
if (childWin[i] && !childWin[i].closed) childWin[i].close();
}
}
window.onunload=function() { closeWin(); }
</script>
<a href="page.html" target="_blank" onClick="return openWin(this)">Pop</a>