Click to See Complete Forum and Search --> : Loading two frames with Javascript


Rik Comery
10-10-2003, 10:52 AM
Hi.

I am having a small problem loading a page into an IFrame with JavaScript.

Basically, i have a single page (which i will call index) with an IFrame (which i will call content) embedded.

What i need is a link in the "index" page which a) reloads the index page and b) loads a different page in the content frame. You may ask why bother refreshing the index page, but there is some other javascript happening to this page, so this is essential.

My problem is, once the index page reloads, the ORIGINAL IFrame file is loaded as well. I cannot get the IFrame to change to the new page.

Below is the sort of script i am trying to run




<html>
<script type="text/javascript" language="JavaScript">
<!--
function loadFrames()
{
document.location.href = document.location.href + "?newParam=test"
window.main.location = "page-b.htm";
return true
}
//-->
</script>
</head>

<body>
<table border="0" cellpadding="3" cellspacing="0" width="100%" align="center">
<tr>
<td><a href="#" onClick="loadFrames(); return false">Link</a></td>
</tr>
<tr>
<td><iframe src="page-a.htm" name="main"></iframe></td>
</tr>
</table>
</body>
</html>


Maybe i am missing something simple. Can anyone help me spot it?

jbergthorson
10-10-2003, 11:03 AM
could you not just put index in an iframe as well? then index would be seperate from the other iframe and you can load stuff into them without worrying about index also refeshing content.

know what i mean?

MainPage
|
------------
| |
index content

make index the size of MainPage if you want and just make it underneath content.

they can access eachother via parent.conent or parent.index

hope that helps, or at least gives you an alternate idea.

jason

jbergthorson
10-10-2003, 11:05 AM
stupid spacing gets removed in the posts...blah. that stuff with the --------- and | etc is supposed to be a tree structure... but it was just eye candy anyways :p

diamonds
10-10-2003, 11:38 AM
Try:

<a href='frame1SRC' target='frame1name' onclick="frame2name.href='frame2SRC'">text</a>