Click to See Complete Forum and Search --> : change 2 iframe with one click?
messyhouse806
04-26-2003, 05:51 AM
hi there, i was wondering if anyone can help me with my problem.
I have a page which consists of a table that has 2 iframes in it. My question is if there is anyway in which clicking on a link within the table (not in iframe) can possibly change the content of both iframes at the same time. If not, are there any simple javascript codes that can do this?
I thank you for your help.
(if this message has appeared twice I apologize)
khalidali63
04-26-2003, 06:52 AM
This is how you can do that.
1. create a link
< ahref="javascript:Process()"> Change IFrames</a>
2. Suppose both of your iframes has name attributes
<iframe name="iframe_1" src="xx.html">
<iframe name="iframe_2" src="xx.html">
3. In the javascript code sction define the Process() function which we intend to call when the link above is clicked.
4. function deffinition
function Process(){
//we want to access both Iframes
parent.iframe_1.document.formName.elementName.value=""
parent.iframe_2.document.formName.elementName.value=""
//above lines how how to access form fields and change their values in both iframes at same time
}
Charles
04-26-2003, 07:17 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>IFRAME example</title>
<p>But JavaScript fails for one in ten users. If we were talking here about old fashioned frames then I would suggest multiple frame sets but that's not practical with inline frames. The solution is to use JavaScript to draw the JavaScript dependent links and to use the NOSCRIPT element to present the two links necessary for the JavaScript free.</p>
<iframe src="http://www.w3c.org/" name="one"><a href="http://www.w3c.org/">W3C</a></iframe>
<iframe src="http://www.w3c.org/" name="two"><a href="http://www.w3c.org/">W3C</a></iframe>
<div>
<script type="text/javascript">
<!--
document.write('<a href="#">Change IFRAMEs</a>');
document.links[document.links.length-1].onclick = function () {
document.frames.one.location="http://www.w3.org/TR/REC-html32";
document.frames.two.location="http://www.w3.org/TR/html4/";
return false;
}
// -->
</script>
<noscript>
<a href="http://www.w3.org/TR/REC-html32" target="one">3.2</a><br>
<a href="http://www.w3.org/TR/html4/" target="two">4.01</a>
</noscript>
</div>
messyhouse806
04-26-2003, 06:27 PM
hey guys thanks for the help. I really appreciate it.
Still, a slight problem remains. The problem is that, for the 2 inline frames to be updated, I would like to use a "Submit" button that would change these items in question. The code works extremely well using <a href> links but I can't get it to work using a form button..argh! Anyway, I'd be very grateful for help on this matter again. And thanks for the javascript code...I'm trying to think of many ways to put it to good use :D