View Full Version : Help with iFrames and Javascript
jbjohn942
09-29-2005, 07:53 PM
I know it can be done, because I've seen it before and was hoping one of you could help. I have on page with an iframe that I want to load different documents in. I want to be able to click on a link from another page that will tell the iframe what to load. This will be passed through the clicked linke (i.e. http://www.domain.com/index.htm?iframeurl=one.htm). I know how to do it with php, but i don't want to go that route just yet. Can anyone help me come up with the javacript code needed to pull this off? Thanks in advance!
Jbjohn942
magicyte
07-08-2008, 07:11 PM
Yeah. Easy.
<iframe src="whatever.html" id="html" name="html" width="200" height="200">Whoops!! Your internet browser doesn't support iFrames.</iframe> <input type="button" value="Clik" onclick="html.location.href='yada.html';">
You guys are just plain fun.
-magicyte
P.S. (WOO HOO! THIS IS MY HUNDREDTH POST! AFTER I PRESS THE POST QUICK REPLY BUTTON, I WILL BE A REGULAR CODER! WHOOPEEE!!!)
rangana
07-09-2008, 12:07 AM
Please excuse me, but magicyte, your code does'nt work on FF.
This line throws an error:
<input type="button" value="Clik" onclick="html.location.href='yada.html';">
Maybe you mean something like this instead:
<input type="button" value="Clik" onclick="document.getElementById('html').src='yada.html';">
Here's the correct code working in all browsers:
<iframe src="whatever.html" id="html" name="html" width="200" height="200"></iframe>
<noframes>
<h2>Sorry, your browser doesn't support frames. Please enable frames or use a different browser to continue.</h2>
</noframes>
<input type="button" value="Click" onClick="document.getElementById('html').src='yada.html';">
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.