Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Multiple targets using one href using iframes in javascript example

Posted on 2008-10-15
5
Medium Priority
?
366 Views
Last Modified: 2013-11-11
I have a frame_index.cfm page that defines 8 separate frames displayed on one page.  With these 8 frames open, I'm trying to go from Frame1 with an <href .. to populate iframe2 and iframe3.  Presently I go from Frame1 to Frame2 as follows,

<a href="../frame2.cfm?jobnum=#jobnum#" target="iframe2">#jobnum#</a>


Once Frame2 is populated I select another <href to populate Frame3 as follows,

<a href="../frame3.cfm?jobnum=#jobnum#" target="iframe3">#jobnum#</a>

The targets, "iframe2" and "iframe3" are used to go through the frame_index.cfm page below.

.
.
.
<td><iframe name=iframe2 src="http://IP/frame2.cfm" width="425"  height="250">                     </iframe></td>
     <td><iframe name=iframe3 src="http://IP/frame3.cfm" width="475" height="250"></iframe></td>
.
.
.

I tried to use the following javascript example, and it almost works for my application. I'm sure how to incorporate the target names to this javascript example.


<SCRIPT language="JavaScript">
function change2()
{
  parent.iframe2.location="http://IPaddress/frame_index.cfm";
  parent.iframe3.location="http://IPaddress/frame_index.cfm";
}
</SCRIPT>

<A HREF="javascript:change2('#jobnum#');">#jobnum#</A>


This kind of works except the entire page of 8 frames opens up in frame2 and frame3 instead of just those frame2.cfm and frame3.cfm pages by themselves.  So it looks like the entire frame_index.cfm page is called instead of each frame going to their individual targets
<iframe name=iframe2 and <iframe name=iframe3.
0
Comment
Question by:talahi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 22728883
If the page for frame 2  is
../frame2.cfm?jobnum=#jobnum#

how can you expect
http://IPaddress/frame_index.cfm

to be what you want?

If you only want ONE cfm, then pass the frame number and handle it in the cf

http://IPaddress/frame_index.cfm?frame=2&jobnum=#jobnum#

Like this

<SCRIPT language="JavaScript">
function changeAll(jobnum) {
  for (var i=1;i<=8;i++) window.frames["iframe"+i].location="http://IPaddress/frame_index.cfm?frame="+i+"&jobnum="+jobnum;
}
</SCRIPT>
 
<A HREF="#" onClick=changeAll('#jobnum#'); return false">#jobnum#</A>

Open in new window

0
 

Author Comment

by:talahi
ID: 22730756
I want to populate 2 distinct frames ("http://IP/frame2.cfm and "http://IP/frame3.cfm) with the selection of 1 href selection.  Within the http://IP/frame_index.cfm page are 2 target names, (iframe2 and iframe3 below)

frame_index.cfm page
.
.
<td><iframe name=iframe2 src="http://IP/frame2.cfm" width="425"  height="250">                     </iframe></td>
     <td><iframe name=iframe3 src="http://IP/frame3.cfm" width="475" height="250"></iframe></td>
.
.
.
where I want the href selection to be directed.  Right now I can do the following,

<a href="../frame2.cfm?jobnum=#jobnum#" target="iframe2">#jobnum#</a>  This href selection will populate the frame2.cfm page with a new jobnum.  The problem is I want this one href selection to populate both frame2.cfm and frame3.cfm with one click.  I believe the JS is the way to do it but I do not know the proper way to script this function.  Like I said what I have kind of works but it seems to ignore the Target or Frame names (iframe2, iframes3)  and replicates ALL 8 frames within the frame2.cfm and frame3.cfm pages.

 
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 600 total points
ID: 22731087
<a href="../frame2.cfm?jobnum=#jobnum#"
onClick="window.frames['frame3'].location='../frame3.cfm?jobnum=#jobnum#';"
target="iframe2">#jobnum#</a>
0
 

Author Comment

by:talahi
ID: 22732006
Thanks, it works with the following modifications, changing 'window' to 'parent' and adding  target="iframe2" to href.

<a href="../frame2.cfm?jobnum=#jobnum#" target="iframe2"
onClick="parent.frames['iframe3'].location='../frame3.cfm?jobnum=#jobnum#';"
target="iframe3">#jobnum#</a>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 22732787
No. You cannot have two targets

My code had target="frame2" too

<a href="../frame2.cfm?jobnum=#jobnum#"
onClick="window.frames['frame3'].location='../frame3.cfm?jobnum=#jobnum#';"
target="iframe2">#jobnum#</a>

And window.frames should have worked the same as parent.frames
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

604 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