Solved

Change two iFrames with one link

Posted on 2012-03-21
5
403 Views
Last Modified: 2012-04-19
Is there a way to make two iframes change to different pages with one external link on the main page? I want to make a page show one image and one content with the click. I have both frames working but the user has two click two different links. Is there a away to make one link change both at the same time?
0
Comment
Question by:Turfimage
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:bigeven2002
ID: 37750646
Hello,

Changing 2 iframe sources with one click would require javascript.

<html>
<body>
<script language="javascript" type="application/javascript">
function framechange(x,y){
    document.getElementById('iframe1').src = x;
    document.getElementById('iframe2').src = y;
}
</script>

<p>
<a href="#" onclick="framechange('image.jpg','content.html');">Click here to change iframes</a>
</p>

<iframe id="iframe1" src="" width="250" height="250" ></iframe>
<br /><br />
<iframe id="iframe2" src="" width="250" height="250" ></iframe>

</body>
</html>

Open in new window


The parameters are relative path to the main document.  You can put an absolute path in there if you wanted as well.
0
 

Author Comment

by:Turfimage
ID: 37791172
What if I had two iframez "iframez" and "iframezTOC" and I wanted one link "Read" to change both the iframez?

Would I change this? I cant seem to get it to work right.

document.getElementById('iframe1').src = x;
document.getElementById('iframe2').src = y;
0
 
LVL 17

Expert Comment

by:bigeven2002
ID: 37791517
Can you post the full code you are currently trying?
0
 

Author Comment

by:Turfimage
ID: 37791931
http://timapserver.com/lettis/ceus-ssc-2/Report/Chapter1.html
Here is the site I left the java script but took out the link code so it would work for now... I'm trying to make the "HTML" link on the right open both iframez at once... The larger reading pane is called "iframez" and the navigation is called "iframezTOC". If you open the PDF link or search link you will see that the HTML link needs to open both the chapter.HTML and the table of contents HTML. Thank you for your help
0
 
LVL 17

Accepted Solution

by:
bigeven2002 earned 200 total points
ID: 37792259
Thanks for posting, but since you took the link code out, I can't see the error.  Looking at the anchor tag for View HTML though, this should work:
<a href="#" onclick="framechange('Chapter1/1Info.html','Chapter1/1TOC.html');"> View HTML</a>

Open in new window


If this failed last time like this, maybe the arguments are pointing to the wrong path.  You might need to make the path absolute:
<a href="#" onclick="framechange('/lettis/ceus-ssc-2/Report/Chapter1/1Info.html','/lettis/ceus-ssc-2/Report/Chapter1/1TOC.html');"> View HTML</a>

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question