Click to See Complete Forum and Search --> : Changing Iframe source


xlegend
07-14-2003, 09:33 AM
How do I change the iframe source using a link and javascript?

I tried this
<html>
<head>
<script type="javascript">
function Rocket();
{
var rocket="New.html"
document.form1.frame1.src=rocket
}
</script>

<Body>

<form name='form1'>
<a href="javascript:rocket();">Rocket</a>
<iframe name="frame1">
</body>
</html>
</head>

Charles
07-14-2003, 09:43 AM
You need no form and you need no JavaScript. Just give the IFRAME a name and use that name as the value of the "target" attribute of the A element.

<a href="http://www.w3.org/" target="overThere">W3C</a>

<iframe src="" name="overThere"></iframe>

xlegend
07-14-2003, 01:23 PM
I need to know how to do one more thing. I have another iframe on the same page.

The page that is loaded into frame one has links that are supposed to load in frame2. I was wondering how to get the links in frame one to load pages in frame2? Can anyone help?

David Harrison
07-14-2003, 02:16 PM
Do the same thing again, for instance; if this was a link in frame 1:

<a href="http://www.w3.org" target="frame2">

it would load the W3C website into frame 2.

xlegend
07-14-2003, 02:30 PM
Thanks