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?
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?