> but both of the child windows the parent is same.
No, this isn't the case.
> when i open the first child window then the parent should be disable .when i close the first
> child window then the parent window should be enable
<!-- s.html -->
<html>
<head>
<title>s.html</title>
<SCRIPT >
my_window = null;
function popuponclick() {
my_window = window.open("p.html","myP", "status=1,width=750,height=450,resizable=no,modal");
}
function check() {
if(my_window && !my_window.closed)
my_window.focus();
}
window.onload = function() {
window.name = "s.html";
}
</script>
</head>
<body onclick="check();" onfocus="check();">
<p>
<a href="#" onclick="popuponclick();">show popup window</a>
<br />
<a href="#" onclick="window.close();">close popup window</a>
</p>
</body>
</html>
<!-- p.html -->
<html>
<head>
<title>p.html</title>
<script language = javascript>
my_window = null;
function popuponclick()
{
my_window = window.open("w.html","myW", "status=1,width=750,height=450,resizable=no,modal");
}
function check()
{
if(my_window && !my_window.closed)
my_window.focus();
}
window.onload = function() {
window.name = "p.html";
alert("Parent of p.html: " + opener.name);
}
</script>
</head>
<body onclick="check();" onfocus="check();">
<p>
<a href="#" onclick="popuponclick();">show popup window</a>
<br />
<a href="#" onclick="window.close();">close popup window</a>
</p>
</body>
</html>
<!-- w.html -->
<html>
<head>
<title>w.html</title>
</head>
<script type="text/javascript">
window.onload = function() {
alert("Parent of w.html: " + opener.name);
}
</script>
<body>
<p>
<a href="#">show popup window</a>
<br />
<a href="#" onclick="window.close();">close popup window</a>
</p>
</body>
</html>
Though the above code works, it has some major problems.
◄ All the above files have a DOCTYPE declaration missing which is a bad thing causing the browser to go in quirks mode.
◄ Instead of directly attaching event listeners to event handlers, one should use addEventListener / attachEvent.
◄ Place all your Javascript in an external file instead of keeping it in each and every file.
◄ Make sure that you keep your tag names in lowercase.