• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

iFrame - open second page and close the first

I have a link that brings up a login form in a iFrame.  At the bottom of the form I have a link to open another form to sign up.  I want the link to close the iFrame with the login form and replace it with the signup form.  Here is the link I am trying but it opens a new window.  I have tried parent and self.

This is the link at the bottom of the login form -

<label><a href="testsignup.html" target="self.frames['iframe2'].location="testsignup.html">Or click here to sign up</a></label>

Any help is appreciated.
0
JohnMac328
Asked:
JohnMac328
  • 9
  • 8
  • 2
1 Solution
 
cfEngineersCommented:
top.frames['iframe2'].location.href="testsignup.html";
or
self.frames['iframe2'].location.href="testsignup.html";
0
 
JohnMac328Author Commented:
parent, self and top don't work - they open a new window
0
 
cfEngineersCommented:
what about document.

also you can use document.getElementById("iframe2").location.href=

just make sure you set <iframe id="iframe2" ... </iframe>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JohnMac328Author Commented:
First I don't use frames very much and why is the link displayed twice - it seems that it is not even looking at the iFrame part in the link and do you have the syntax for document.getElementById("iframe2").location.href=
0
 
cfEngineersCommented:
I missed something in your code

<label><a href="testsignup.html" target="self.frames['iframe2'].location="testsignup.html">Or click here to sign up</a></label>

change to

<label><a href="testsignup.html" target="iframe2">Or click here to sign up</a></label>
0
 
JohnMac328Author Commented:
Still opens up another window
0
 
cfEngineersCommented:
please paste the html.

If you do not have an <iframe name="iframe2"></iframe>
 then this will pop another window.



0
 
JohnMac328Author Commented:
Here is the html page with iFrame2
<body>
<table border="0" width="300" align="center" cellpadding="0" cellspacing="3" bgcolor="#35679a"><tr>
<td><table border="0" width="100%" align="center" cellpadding="0" cellspacing="6" bgcolor="#B9D4E6"><tr>
<td><iframe name="iframe2" src="AA_MembershipSignup.cfm"  width="100%" height="500"  scrolling="no"  frameborder="0">[Your user agent does not support frames or is currently configured not to display frames.]</iframe></td>
</tr></table>
</td></tr>
</table>
</body>

Open in new window

0
 
cfEngineersCommented:
so is the <label><a href="testsignup.html" target="iframe2">Or click here to sign up</a></label> loaded inside the iframe?

is so just remove the target all together.
0
 
JohnMac328Author Commented:
It opens up just like it should except in a new window instead of replacing the first iframe
0
 
cfEngineersCommented:
would you mind pasting your code that gets loaded into the iframe as well?
0
 
JohnMac328Author Commented:
Would rather not for security reasons - it is just a simple form taking name, email etc and then it is submitted.  It works fine except it is on another page
0
 
_agx_Commented:
Just curious, but why close the iframe? If you're just going to reopen it anyway, I'd think a plain link (no target) should work fine

YourLoginPage.cfm
=================
<form>
       .....
       <a href="YourSignupPage.cfm">...Or click here to sign up</a>
</form>
0
 
cfEngineersCommented:
@aqx, thats what i suggested as well #35707974
0
 
_agx_Commented:
thats what i suggested as well

Ah, so you did.  My bad.  I just kept seeing references to target, self, parent. I was scratching my head thinking "what's wrong with a plain old link" ;-)
0
 
cfEngineersCommented:
same here perhaps

when i suggested removing target it ended up target=""?
0
 
JohnMac328Author Commented:
Well I thought I tried that and it didn't work but that was my error because it did work.  
0
 
JohnMac328Author Commented:
So embarrassing - Thanks for the help
0
 
cfEngineersCommented:
Awesome, glad to help
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 8
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now