Forum Moderators: open

Message Too Old, No Replies

DHTML: Hide a <div> from an iframe.

My page contain a Iframe that I want to hide.

         

fmaz

5:07 pm on Nov 25, 2004 (gmt 0)

10+ Year Member



ok, I've a page that contain a <div> that contain an <iframe>.

In the iframe, I want to be able to hide the <div> (this will also hide the <iframe>

Ps.: I MUST have the <iframe> in the <div>.


The code
------------------------------------
<script language="javascript">
function showaction(url) {
document.getElementById("pjaction").style.visibility = "visible";
document.getElementById("pjactionifrm").src="?popup=1&pj=" + url;
}

function hideaction() {
document.getElementById("pjaction").style.visibility = "hidden";
}
</script>

<div id="pjaction" class="pjpanel" style="position:absolute;top:10px;left:10px;width:802px;height:530px;visibility:hidden;">
<iframe id="pjactionifrm" src="?popup=1&pj=a_empty" style="width:800px;height:500px;"></iframe><br />
<center><a href="#" onclick="hideaction();">-- Fermer --</a></center>
</div>
------------------------------------

The code in the page of the iframe that must close the pjaction <div>:
------------------------------------
<script type="text/javascript">
window.getElementById("pjaction").style.visibility = "hidden";
</script>
------------------------------------

But this code doesn't want to hide the div :(
document.getElem... also doesn't work.

Bernard Marx

5:29 pm on Nov 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



window.getElementById("pjaction").style.visibility = "hidden";

You need to refer to the div via
1. The main window
2. that window's document

So you've slipped up a little there.
I hope this will work:

top.document.getElementById("pjaction").style.visibility = "hidden";

fmaz

5:56 pm on Nov 25, 2004 (gmt 0)

10+ Year Member



Thank's!