how to disable the parent window when we open the child window. i have written this code but its working only one time.any one can help me

s.html


<html>
<head>
<SCRIPT >
function popuponclick()
{
my_window = window.open("p.html",
"mySelect", "status=1,width=750,height=450,resizable=no");
}

</script>
</head>
<body>
<form name="formSelect">
<P>
<A HREF="#" onclick='popuponclick()' >show popup window</A><br>
</P>
</div>
</form>
</body>
</html>

p.html

<html>
<head>
<script language = javascript>
</script>
</head>
<body onBlur="self.focus()">
bbb

</body>
</html>

Recommended Answers

All 3 Replies

what do you mean by disable parent window? do you want to close it?
If so, forget about it - JavaScript able to close windows that open by JS only.

Try these instead:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hielo's Parent Page</title>
</head>
<body>
<script type="text/javascript">
var child_window=null;
var parent_window=window;
function popUponClick()
{
    child_window = window.open("p.html", "mySelect", "status=1,width=750,height=450,resizable=no");
    parent_window.onclick = blurify;
    parent_window.onfocus = blurify;
return false;
}
function blurify()
{

    if(child_window)
    {
        if(parent_window)
            parent_window.blur();
        child_window.focus();
    }
}

</script>

<form name="formSelect">
<p><a href="#" onclick='return popUponClick();'>show popup window</a><br /></p>
</div>
</form>
</body>
</html>


========================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hielo's Child Page</title>
<script type="text/javascript"><!--
var parent_window = window.opener;
var child_window = window.self;
function closeIt()
{
    if(parent_window)
    {
        if(window.ActiveXObject)
        {
            child_window.blur();
            parent_window.focus();
        }
        parent_window.close();
        child_window.focus();
        parent_window=null;
    }
}
//--></script>
</head>
<body>
<form action="." method="POST">
<input type="button" value="Close Parent" onclick="closeIt();"/><input type="button" value="Close Me" onclick="self.close();"/>
</form>
</body>
</html>

It has already been solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.