Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide a Div on a parent page. 1

Status
Not open for further replies.

ironhide1975

Programmer
Joined
Feb 25, 2003
Messages
451
Location
US
I have an iFrame that is enclosed in a hidden DIV, when a person clicks the SHOW button, the iFrame pops up and shows a selection of files. I want it so when the user clicks on the file in the iFrame it closes the parent page's DIV that contains it. Can anyone show me how to do this?

I think it's something like this


Code:
window.parent.nameofdiv.style.display = 'none';

 
Here's a quick example:
Code:
[!]test.html[/!]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">


</script>
<style type="text/css"></style>
</head>
<body>

<div id="theDiv" style="display:none">
   <iframe src="test2.html"></iframe>
</div>

<input type="button" value="show div" onclick="document.getElementById('theDiv').style.display = 'block'" />

</body>
</html>

Code:
[!]test2.html[/!]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript"></script>
<style type="text/css"></style>
</head>
<body>

<input type="button" value="hide div" onclick="[!]parent.document.getElementById('theDiv').style.display = 'none'[/!]" />

</body>
</html>

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top