show div outside of iframe

here is what i have set up

base page > iframe > iframe > button

i want to be able to click button and "show" a div named email located on base page

thank you
Who is Participating?
ljfernandezConnect With a Mentor Commented:
Here you go:

 var emaildiv = window.parent.frames["rightGiveImageShow"].document.getElementById("email");'visible';
As long as you have positioned the <div> through a CSS positioning statement (either absolute or relative) you can set it's z-index to be at a level above the base page. You also need to set its visibility to "hidden". Then write a javascript function to change its visiblility property ie document.getElementById(id).style.visibility = "visible"; where id is the name of the <div>. You then call this javascript fiunction with an 'onClick' statement attached to the button.

To reference the <div> from within the nested iframes you will either:
1. Attach the javascript function to the base page and the 'onClick' statement will have to reference the function by parent.parent.javascriptFunctionName() or top.javascriptFunctionName()
2. Alternatively place your function at the same level as the button and use parent.parent.document.getElementById(id).style.visibility = "visible"; in the function.

I hope this helps

qwertqAuthor Commented:
this does not seem to work....

at the top level i have:
<div id="email" style="position:absolute; left:387px; top:180px; width:263px; height:208px; z-index:1; visibility: hidden;">
  <iframe src="email.php" frameborder="0" width="239" height="250" scrolling="no" name="emailFrame"></iframe>

on the page contained within two iframes i use this as my href:
<a href="javascript:parent.parent.document.getElementById(email).style.visibility='visible';">

having it appear over the iframe is not a problem, that works (but only works with a button action on the same page as the div)

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

qwertqAuthor Commented:
anyone? i still have not figured it out...
i will increase the points if that is why no one is answering
Nothing is going to show OVER the iframe. It's a separate document, and will override anything on the base page.

I would consider redesigning this if that's the effect you want to get. Or, open your overlay in a new window, and position that. A new window WILL overlay anything else on the page -- it's a window, not a frame, and since you open it you control it.
qwertqAuthor Commented:
my div does appear over an iframe, that works fine. that is not my problem.

BASE PAGE > iframe > iframe > BUTTON

i am what the code would be to set a (on base page) div to visible by clicking BUTTON

This works in IE:

<input type="button" value="Click to show email iframe in base doc" onclick="showDiv()"/>

<script language="javascript">
function showDiv()

or you could try:
   var emaildiv = window.parent.window.parent.document.getElementById("email");'visible';
qwertqAuthor Commented:
i could cry, it works!

is this IE only thou? i tested it on netscape 7 and it does not work.
The 2nd version of the script works for me in Netscape 7.

qwertqAuthor Commented:
oh, you are right. sorry lisa i did not check that one.

one more question. how would i do another
for this set up?

window.parent > iframe named rightGiveImageShow > document.getElementById("email");

not sure how to tie the frame name in there
So in other words I'm thinking you are wanting to access the document of the parent frame instead of the parent frame's parent?

I'm not 100% sure what you're asking but I think what you are looking for is:

var emaildiv = window.parent.document.getElementById("email");


qwertqAuthor Commented:
thank you for bearing with me. sorry its kind of hard to explain...

i want to access a document which is in a different frame on the parent page....

basically go to parent, then into iframe named 'rightGiveImageShow' then change the visibility...

if you have any questions you can email me at, and i will contact you with my real email or aim.
qwertqAuthor Commented:
that worked great....  i just have 1 more to get working i thought i could patch it together from what you gave me but it does not work (i promise this is my list)

i need to go up to parent, into iframe named 'rightBaseFrame', into iframe named 'rightImageFrame', into iframe named 'rightGiveImageShow' and finally hide div named Diag.

i tried both of these:

var diagdiv = window.parent.window.frames["rightBaseFrame"].window.frames["rightImageFrame"].window.frames["rightGiveImageShow"].document.getElementById("Diag");'hidden';

var diagdiv = window.parent.frames["rightBaseFrame"].frames["rightImageFrame"].frames["rightGiveImageShow"].document.getElementById("Diag");'hidden';
qwertqAuthor Commented:
got it :) i think i had a typo.
thanks for all your help
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.