Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Change two iFrames with one link

Posted on 2012-03-21
5
Medium Priority
?
499 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 800 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month20 days, 19 hours left to enroll

810 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