/    Sign up×
Community /Pin to ProfileBookmark

Loading two frames with Javascript

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 [U]different[/U] 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

[CODE]
<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>
[/CODE]

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

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@jbergthorsonOct 10.2003 — 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
Copy linkTweet thisAlerts:
@jbergthorsonOct 10.2003 — 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
Copy linkTweet thisAlerts:
@diamondsOct 10.2003 — Try:
[code=php]
<a href='frame1SRC' target='frame1name' onclick="frame2name.href='frame2SRC'">text</a>[/code]
×

Success!

Help @Rik_Comery spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...