Click to See Complete Forum and Search --> : replacing 2 frames with onClick


js_student66
05-01-2004, 01:40 PM
I'm working on a site where i have 2 frames

when certain links are clicked, i want that page and the main page to be replaced

I took the code right out of the book i used for class, but i am finding that only the main page is begin replaced, not the links page.

I also read that you need to take out the <base target
coding, which i did (I commented out) ... but if i leave it in, both pages are replaced properly, BUT, a totally new window opens with an error.

here's my coding: (frameset)

<frameset cols="20%,*" border="0">
<frame name="leftframe" scrolling="auto" target="main" src="sidenav.htm">
<frame name="mainframe" scrolling="auto" target="main" src="welcome.htm" >
</frameset>

here is the links page that contains the javascript:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- **Remove** <base target="main"> -->

<script language="JavaScript1.2" type="text/javascript"><!--
function loadFrames(mainSrc, navSrc) {
parent.mainframe.location.replace(mainSrc);
parent.leftframe.location.replace(navSrc);
}
-->
</script>
</head>

<p><a href="javascript:void(0);"
onClick="loadFrames('background.htm','sidenav.htm')">background</a><br>
<a href="javascript: void(0);"
onClick="loadFrames('links.htm','sidenav.htm')">Links</a><br>
<a href="javascript: void(0);"
onClick="loadFrames('pics/picshome.htm','sidenav.htm')">Photos</a><br>
<a href="javascript: void(0);"
onClick="loadFrames('tips.htm','sidenav.htm')">Tips</a><br>


Hope this is enough to figure out what the heck i'm doing wrong.....

(though i'm contemplating chuckin' the whole thing and using tables - which i dont like, but will do the trick)

Thanks in advance,

Terese

ShrineDesigns
05-01-2004, 02:11 PM
remove taget="main" from the frames

try this:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript">
<!--
function load_link(url)
{
parent.leftframe.location.href = url;
}
//-->
</script>
</head>
<body>
<a href="main.html" target="mainframe" onclick="load_link('page.html')">link</a>
</body>
</html>

js_student66
05-01-2004, 04:29 PM
Well, i took out the target=main (thanks... forgot about those) in the index file

but...... now nothing works, using the load_link function

what my leftframe is... is a bunch of links to different pages on the site.

i have the first one that has all the links, and when you click
*Journal* a different page opens up in that frame (basically, expanding the journal pages, all 55 of them -- plus all the other links.

but when a link that is NOT a journal page is clicked, it is supposed to go back to the original links (sidenav.htm) and open the corresponding page in the main frame.

I know it can work... but if i can't get it to... i'll can the whole thing and try something different.


anything else i can try......??

TIA,

terese

**edit**

Hmmmmm, now after getting the file to what it originally was, less the Target=main in the index.htm
now when i click on a journal page - that used to open in the mainframe, it now opens in the sideframe.

so.. obviously none of the js is working -- and i dont get any errors. (i'm working in IE6 btw)

ShrineDesigns
05-01-2004, 05:24 PM
i got it to work why can't you lol

js_student66
05-01-2004, 08:21 PM
now i've completely re-done the page using your code....
but -- me not being very good at JS,
i can't just guess what goes where....
sometimes an explanation is easier than saying...
"here try this.... "

you posted
<!--
function load_link(url)
{
parent.leftframe.location.href = url;
}
//-->
</script>
</head>
<body>
<a href="main.html" target="mainframe" onclick="load_link('page.html')">link</a>
</body>


the function part i just entered the url for the page that needs to go there.

but for the
<a href="main.html and 'page.html'

since i do not have pages by those names -- I chose the files i thought went there....
and i can get the link to open in the mainframe, but I cant get the second frame (sidenav.htm) to change back..
and that was the whole idea of this... to get 2 frames to change with the onClick.

well..... thanks for your assistance