talahi
asked on
Multiple targets using one href using iframes in javascript example
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.
<a href="../frame2.cfm?jobnum
Once Frame2 is populated I select another <href to populate Frame3 as follows,
<a href="../frame3.cfm?jobnum
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('
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.
ASKER
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.
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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['if rame3'].lo cation='.. /frame3.cf m?jobnum=# jobnum#';"
target="iframe3">#jobnum#< /a>
<a href="../frame2.cfm?jobnum
onClick="parent.frames['if
target="iframe3">#jobnum#<
No. You cannot have two targets
My code had target="frame2" too
<a href="../frame2.cfm?jobnum =#jobnum#"
onClick="window.frames['fr ame3'].loc ation='../ frame3.cfm ?jobnum=#j obnum#';"
target="iframe2">#jobnum#</a>
And window.frames should have worked the same as parent.frames
My code had target="frame2" too
<a href="../frame2.cfm?jobnum
onClick="window.frames['fr
target="iframe2">#jobnum#</a>
And window.frames should have worked the same as parent.frames
../frame2.cfm?jobnum=#jobn
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
Open in new window