Click here to Skip to main content
15,915,164 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I want to acces the div & hide it div of parent window from child windo,

the all code is here, but the bold line in child window must be changed,,, I am using IE,, .what should be change in place of bold line

as the child window is display the div is hide,let suppose the div has loading.gif pic....

I am using IE

Parent Window
XML
<script type="text/javascript">
function openwindow()
{
window.showModalDialog("default4.aspx")
//retval=window.showModalDialog("default4.aspx")
//document.getElementById('text1').value=retval
}



XML
</script>
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
<form name="frm" runat="server">
<input name="text1" type="text">
<input type="button" onclick="javascript:openwindow()" value="Open window..">

<div id="test">

This must be hide</div>

<div>

No CHange
</div>
</form>
</body>
CHild window
<head id="Head11" runat="server">
    <title>Untitled Page</title>
</head>
<script type="text/javascript">
window.onload=function changeparent()
{
//window.returnValue="Value changed.."
window.parent.document.all("test").style.visibility = "hidden" ;
}
</script>

<body>
<form id="aa" runat="server">
<input type="button" onclick="javascript:changeparent()" value="Change main window’s textbox value.." />
</form>

</body>
</html>
Posted
Updated 20-Aug-12 7:33am
v2

Technically speaking the child window and parent window are two different instances of the browser. We call them as child window and parent window. They do not have access to each other.So its not possible to perform any action in one window on the click of HTML elements in second window.
 
Share this answer
 
Hi,

If your one window is open the another then below code may work for you,

JavaScript
window.opener.getElementById('parentDivId').style.visibility ="hidden";


Give it a try and let me know

Thanks
-Amit Gajjar
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900