accessing parent container from IFrame

K

Katie

I create a div in which i insert an iframe. The iframe itself gets
populated by the pbm_forms target submit.

All this happens fine, and I get the IFrame with the required content.
The problem is that I want to be able to close the containerDiv (hide
it using css) from within the IFrame. Unfortunately I am having
permission issues and can't seem to figure out how I can close the
IFrames containing div from within the IFrame.

My code for creating the iframe and populating it is below

var containerDiv = parent.document.createElement("div");

containerDiv.innerHTML = '<iframe src="about:blank"
allowtransparency="true" marginwidth=0 marginheight=0 scrolling="no"
frameborder=0 width =' + iframe_width + ' height=' + iframe_height + '
name="main_iframe" id="main_iframe"></iframe>' + "<form id=\"pbm_form
\" name=\"pbm_form\" target=\"main_iframe\""
+ "</form></div><div class='clearer'><!-- --></div><div
id='pbm_lbox_footer'><!-- --></div>";

containerDiv.id = "main_container";

parent.document.body.appendChild(containerDiv);


Thank you for your time and help :)
 
S

SAM

Katie a écrit :
I create a div in which i insert an iframe. The iframe itself gets
populated by the pbm_forms target submit.

All this happens fine, and I get the IFrame with the required content.
The problem is that I want to be able to close the containerDiv (hide
it using css) from within the IFrame. Unfortunately I am having
permission issues and can't seem to figure out how I can close the
IFrames containing div from within the IFrame.

Don't understand ... that works fine with my Fx, Safari,
with displayed in the iframe the file :

'test_close_iframe.htm' :
<html>
<a href="#"
onclick="parent.document.getElementById('main_container').style.display='none';
return false;">close iframe</a>
My code for creating the iframe and populating it is below

<script type="text/javascript">
function hop(iframe_width, iframe_height) {
var containerDiv = document.createElement("div");
containerDiv.innerHTML = '<iframe src="test_close_iframe.htm" '+
'border=4 width=' + iframe_width + ' height=' + iframe_height +
' name="main_iframe" id="main_iframe"><\/iframe>' +
'<form id="pbm_form" name="pbm_form" >' +
'<\/form><\/div><div class="clearer"><!-- --><\/div>' +
'<div id="pbm_lbox_footer"><!-- --><\/div>';
if(!document.getElementById('main_container')) {
document.body.appendChild(containerDiv);
}
else {
document.body.replaceChild(containerDiv,
document.getElementById('main_container'));
}
containerDiv.id = "main_container";
}
</script>
<p><a href="#" onclick="hop(400,300);return false;">new iframe</a></p>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top