Click to See Complete Forum and Search --> : More divs and mouseover


IxxI
02-05-2003, 02:55 PM
I have a div box that is hidden by default but becomes visible as the mouse moves over a link to display some text in a frame. I have about 10 links instead of creating a differentdiv box and show code for each of them is it possible to use variables in javascript to use the same div box to show different text depending upon which link the mouse is over?
The code I'm using can be seen about half way through the post at:
http://forums.webdeveloper.com/showthread.php?s=&threadid=3622
Help would be much appreciated, thanks,
IxxI

khalidali63
02-05-2003, 03:13 PM
If I understand your question correctly, this is what you need to do

window.top.iframe.main.document.getElementById("mainbox").innerHTML = Your variable here

it will display any value in the variable within that div element.

cheers

Khalid

IxxI
02-05-2003, 03:44 PM
I want to specify the value of a set of variables as lines of text, and then use eval() to display the text. This is the code I've tried to use but it doesn't work I get an expected ; error. Though I don't think that's the problem:

var page1 = "This text should appear in the div box in my main frame when I move over the link to page 1."
var page2 = "And this should come up when I move my mouse over page2."

function showbox(text) {
window.top.iframe.main.document.getElementById("mainbox").style.visibility = "visible";
window.top.iframe.main.document.getElementById("mainbox").InnerHTML.value = eval(text);
}

function hidebox() {
window.top.iframe.main.document.getElementById("mainbox").style.visibility = "hidden";
}
</script>

</HEAD>
<BODY topmargin="4" leftmargin="0" rightmargin="0" BGCOLOR="#C0C0C0" TEXT="#0F0000" ALINK="#0F0000" VLINK="#0F0000" LINK="#000000">
<font face="times new roman" size="5">
<CENTER>
<A HREF="page1.html" target="main" onMouseover="showbox(page1)" onMouseout="hidebox()">Page 1</A>
<A HREF="page2.html" target="main" onMouseover="showbox(page2)" onMouseout="hidebox()">Page 2</A>

I've tried messing around with the showbox code but I'm sure thats the way to do it. nothing happens it I remove the InnerHTML tag either. Please Help!!
IxxI

IxxI
02-05-2003, 04:11 PM
Also is there a way to stop it happening after you've left a certain page. My div box is only on mainpage.html which is the default page of the main frame, however once I've clicked on page1.html there is no longer a div box as I no longer want the descriptive text. Is there a way of telling the browser only to let it work on a certain page, as the links are on seperate frames and so the code is still there. Or do I just have to load a different set of frames? If I navigate away or back from/to the original page.
IxxI