Link to home
Start Free TrialLog in
Avatar of jhson114
jhson114

asked on

how to load different sites in a single iframe depending on a link clicked

im trying to load different site in a single iframe depending on a link clicked.

i have a five buttons. depending on my choice, i want to be able to change the underined part.

<table><tr><td>
<iframe src="____________" width="390" height="80" border="0"></iframe>
</td></tr>
</table>

i would greatly appreciate any help. thanks in advance.
Avatar of jhson114
jhson114

ASKER

basically i want to change the page in the iframe from outside of iframe
ASKER CERTIFIED SOLUTION
Avatar of Andrew Beers
Andrew Beers
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Btw:

http://www.quirksmode.org/js/iframe.html

Nice refrence for browser compatibility and iframe attribs.

~Aqua
nevermind. i found the answer. i dont need javascript. i can do this easily with target="iframename"
<html>

<head>
<title>Change I-Frame</title>

<script language="javascript">
function chgI(goWhere)
{
      document.getElementById("dynamicI").src = goWhere;
}

</script>

</head>

<body>
<table><tr><td>
<iframe id="dynamicI" src="http://www.cnn.com" width="500" height="500" border="0"></iframe>
</td></tr>
</table>
<input type="button" name="btn" value="Go to Google..." onclick="chgI('http://www.google.com');" /><br />
<input type="button" name="btn" value="Go to CNN..." onclick="chgI('http://www.cnn.com');" /><br />
<input type="button" name="btn" value="Go to ESPN..." onclick="chgI('http://www.espn.com');" /><br />
<input type="button" name="btn" value="Go to CollegeHumor..." onclick="chgI('http://www.collegehumor.com');" /><br />
<input type="button" name="btn" value="Go to Startupjournal..." onclick="chgI('http://www.startupjournal.com');" />
</body>

</html>
jhson114 :

You have your solution in javascript and it was there long before you posted your "nevermind"

Bite the bullet and close this question.  That is not right to say "Nevermind"  especially when you only are offering 40 points for the question.  I answered you with your javascript as you posted in the javascript TA, if you would have asked for html I would have given you target="iframeName".

~Aqua
jeeeeeez chill out man. after posting the question, i searched for solution with another IE and when i found the answer, i forgot to refresh the page to see if anyone had posted an answer before commenting that i found the answer. also i dont consider 7 minutes a "long before you posted your nevermind". way to be nice about the situation. like you said its only 40 points. you dont have to be all bitchy about it.