Click to See Complete Forum and Search --> : More div boxes and frames


IxxI
02-06-2003, 05:36 AM
I have a div box in my main frame which becomes visible and shows different text as you move over different links in a second and third frames. 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

IxxI
02-06-2003, 06:51 AM
Is there a way of asking which page is in the the main frame and judging accordingly what to do with it? So if it were mainpage.html then on mouseover it would show the div box, but if it were any other page on mouseover nothing would happen?
IxxI

khalidali63
02-06-2003, 06:55 AM
yes you can do that as long as the page which is loaded in the frame resides onyour server and being served by it.
In your situation if I remember correctly this would be the correct way of getting the loaded page's url

var url = window.top.iframe.main.document.location.href;

at this point you can apply some appropriate condition checkings like

if (url=="anypage.htm){

}else{

}

cheers

Khalid

IxxI
02-06-2003, 07:10 AM
Thanks for the reply. I've tried what you suggested but it doesn't seem to work. Its probably something I'm getting wrong, here's how I've implemented it:

var page1 = "This text should appear on the main page when I move my mouseover this link"

function showbox() {
var url = window.top.iframe.main.document.location.href;
if (url==page1.html)
{
window.top.iframe.main.document.getElementById("mainbox").style.visibility = "visible";
window.top.iframe.main.document.getElementById("mainbox").innerHTML = page1;
}
else{window.status="Page 1";}
}

function hidebox() {
var url = window.top.iframe.main.document.location.href;
if (url==page1.html)
{
window.top.iframe.main.document.getElementById("mainbox").style.visibility = "hidden";
}
else{window.status="";}
}

</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()" onMouseout="hidebox()">Page 1</A>

It now doesn't show any text. Thanks for your continued help.
IxxI

khalidali63
02-06-2003, 07:16 AM
Would it be possible for you to zip all the related files and upload it here..
That will be help full.

Or may be post a link to actual test pages.

cheers

Khalid

IxxI
02-06-2003, 07:38 AM
Ok here it is. If you open iframe.html in whatever browser you're using everything should appear and as you move your mouse over the top links they should work - displaying text in the main window (I couldn't be bothered to do the bottom links yet). However if you click on one and get taken to the Page Not Here! page and then click home the text won't come up as it failed to find the div box on error.html. If you now go into main.html and change where it says empty.html to emptytest.html you now have the code I used from you (but only in page 1's link. If you now re-open iframe.html (refreshing doesn't work) you'll find that no text comes up at all. Thanks for your time, and I hope that this explanation is satisfactory.
IxxI

IxxI
02-06-2003, 07:45 AM
I've also tried what you said Dave, and it didn't seem to work. I'm assuming this is because I'm doing something wrong in my code somewhere. My pages are above!
Thanks,
IxxI

IxxI
02-06-2003, 07:49 AM
Sorry was typing when you posted - I have 3 frames IN an iframe. May not make sense and is probably destroying all sorts of conventions, but it works for what I want. I want to test whether my main frame is called main.html as I move my mouse over a link in another frame.If so then I want to display a div box with some text in, and then hide it as I move my mouse away. If not then I don't want it to do anything as I move my mouse over it.
IxxI

IxxI
02-06-2003, 08:07 AM
I don't judge how you chose to construct your documents -- that is for those who like to criticize. I'm just interested in solving the problems of those who are trying to learn something.

Sorry, I was being sarcastic - I wasn't trying to get at you.
It still doesn't seem to work although your assumption about my layout is right. In the script of the frame with the links in I now have:

var page1 = "This should appear when mouse moves over the link to page 1."

function showbox() {
var url = parent.frames["main"].location.href;
if (url.indexOf("test.html") > (-1)) {
window.top.iframe.main.document.getElementById("mainbox").style.visibility = "visible";
window.top.iframe.main.document.getElementById("mainbox").innerHTML = page1;
} else {
alert(Not the right window!);
}
}

function hidebox() {
var url = parent.frames["main"].location.href;
if (url.indexOf("test.html") > (-1)) {
window.top.iframe.main.document.getElementById("mainbox").style.visibility = "hidden";
} else {
alert(Not the right window!);
}
}

and in my body I have:

<A HREF="error.html" target="main" onMouseover="showbox()" onMouseout="hidebox()">Page 1</A>

If you need more code all the pages are in the zip above. Sorry about all this and thanks for the time you're taking - I just can't figure out where I'm going wrong.
IxxI

IxxI
02-06-2003, 08:18 AM
Thought I'd better post the zip again as its changed so much.
Click on iframe.html to see what my page looks like. test.html is the page with the divbox in and emptytest.html is the page with all the script in (the top set of links).
IxxI

khalidali63
02-06-2003, 08:37 AM
Replace all the instances of
alert(Not the right window!);

witht his

alert("Not the right window!");

It seem to work

khalidali63
02-06-2003, 08:44 AM
and in the showBox functions

you need to add another condition

like change this to

window.top.iframe.main.document.getElementById("mainbox").style.visibility = "visible";
window.top.iframe.main.document.getElementById("mainbox").innerHTML = page2;


with this code

if(window.top.iframe.main.document.getElementById("mainbox")){
window.top.iframe.main.document.getElementById("mainbox").style.visibility = "visible";
window.top.iframe.main.document.getElementById("mainbox").innerHTML = page1;
}

IxxI
02-06-2003, 09:47 AM
Thanks Khalid thats the code I was looking for - it worked perfectly.
IxxI