Click to See Complete Forum and Search --> : Iframe and divs
I was using the visibility of div boxes to show text as the mouse went over certain links in another frame. I have since put these frames into an iframe and the code no longer works.
Here is the code:
<script>
function showbox() {
window.top.main.document.getElementById("mainbox").style.visibility = "visible";
}
</script>
where main is the name of the frame in which the text appears, and mainbox is the name of the div box with the text in. Can anyone think why this might be happening?
IxxI
khalidali63
02-05-2003, 02:14 PM
Regardless of my thinking why you needed to put frames in iframe.you must follow the parent child relationship in referencing any object/frame.
unless some take a look at all of your code,and suggest something for you I can only say that reference iframe using its name.+
Sorry, I didn't explain it very well. I had 3 frames, top, middle and bottom, where the middle one was my main one and the top and bottom were for links. I wanted text to come up in the main box when I moved my mouse over the links. This I achieved with div boxes and help from yourself and gil davis (see div boxes frames and mouseover). I then realised that if people wanted to see it using smaller resolutions I'd have to make the whole thing smaller and centred in higher resolutions, this was achieved with an iframe around all the frames (see more frames). However then the code which made the text come up in the main frame stopped working, although none of the frame names had been changed and all of them had been plonked in the the iframe. This is the code for the links:
<script>
function showbox() {
window.top.main.document.getElementById("mainbox").style.visibility = "visible";
}
function hidebox() {
window.top.main.document.getElementById("mainbox").style.visibility = "hidden";
}
</script>
</HEAD>
<BODY topmargin="4" leftmargin="10" BGCOLOR="#C0C0C0" TEXT="#0F0000" ALINK="#0F0000" VLINK="#0F0000" LINK="#000000">
<font face="times new roman" size="5">
<CENTER>
<A HREF="page 1.html" target="main" onMouseover="showbox()" onMouseout="hidebox()">Page 1</A>
and this is the code in the main frame:
<style type="text/css">
.boxes{
padding: 10px;
}
#mainbox{
visibility: hidden;
}
</style>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" ALINK="#006600" VLINK="#0000CC" LINK="#00FFFF" topmargin=10 leftmargin=10>
<BR><BR>
<font face="arial">
<CENTER>
<div class="boxes" id="mainbox">
this is where my text should appear
</div>
</CENTER>
These frames were in a frameset, and that frameset was then placed in an iframe, so the result looked like that at www.future.co.uk without all the funky graphics etc.
The code worked before it was placed in the iframe but not after. Do I need to call the iframe somewhere in this line window.top.main.document.getElementById("mainbox").style.visibility = "visible"; ?
Sorry for the length and thanks,
IxxI
Webskater
02-05-2003, 02:31 PM
window.top.main.document.getElementById("mainbox").style.visibility = "visible";
Without seeing your frames code its hard to be precise. But I guess you have a page with an iframe on it and, in the iframe a page with two frames.
In this case I would have thought:
window.parent.frames('main'). etc would have found the right frame.
Sorry, should have thought before posting - I changed it to window.top.iframe.main.document.getElementById("mainbox").style.visibility = "visible"; and it worked. Should have read your post more carefully. Sorry and thank you.
IxxI