Page 1 of 1

Need Help w/ iframe and TARGET _parent

Posted: Sat May 23, 2009 3:32 pm
by suburbangypsy
I am not a programmer, nor am I looking to become one in the near future but I am having an issue using an iframe for a CoffeeCup Form Builder form used within WordPress 2.7.1. I have already posed this question to both CoffeeCup and WordPress forums and have not received any answer. I have searched this forum and on Google and am not finding anything to answer my question.

I am using a plugin - Secure and Accessible PHP Contact Form v.2.0 - for my basic contact form on WP, but needed a more extensive form to use as a training program application so I turned to CoffeeCup. I have no issue getting it onto my site using iframe.

My site:

http://cornerstonecoachacademy.com/life ... plication/

My code:

Code: Select all

<iframe src="http://cornerstonecoachacademy.com/application.html" name="Life Coach Training Program Application" scrolling="auto" frameborder="no" align="center" height = "2850px" width = "850px">
</iframe>
Now my issue is that once you hit submit it takes you to the Thank you page within the iframe. Not what I want to do.

The code within the CC two files that call unto that Thank you page are...

The myform.php:

Code: Select all

/**
* The page to redirect to after the form is submitted.
*/
define('CC_FB_RESULTS_REDIRECT', 'http://cornerstonecoachacademy.com/thank-you-for-your-application/');
The myform.xml:

Code: Select all

<hidden
name="thankyoupage"
value="http://cornerstonecoachacademy.com/thank-you-for-your-application/"
></hidden>
What I would like to do is have the new page, the Thank You page, open up in the outer frame, instead of within the iframe. I am assuming I would want to do a target="_parent" but am unsure how to do this or if I can do within the php, which is where I assume the call needs to be made. (Please excuse anything obviously newbie here)

Can you add a target to the php? I do not want to have my page open within the inner frame.

Re: Need Help w/ iframe and TARGET _parent

Posted: Sat May 23, 2009 7:03 pm
by requinix
I don't know how (or even if it's possible) using this CoffeeCup thing - it certainly would be ideal - but you can put some JavaScript inside your thank you page that (a) checks if it is inside the top-level frame, and (b) makes itself so if it is not. It should be right at the top of the page so it gets executed immediately rather than after stuff has begun loading.

Code: Select all

<script type="text/javascript">
if (window != window.top) window.top.location.href = window.location.href;
</script>
Normally I frown on this sort of thing but I don't know of a better way. Maybe somebody else does...

Re: Need Help w/ iframe and TARGET _parent

Posted: Sun May 24, 2009 9:50 am
by straightman
_blank opens the linked document in a new browser window, leaving the current window untouched.
_parent opens the linked document in the parent frameset of the frame the link appears in, replacing the entire frameset.
_self opens the link in the current frame, replacing the content in that frame.
_top opens the linked document in the current browser window, replacing all frames.
Tip: If you’re linking to a page outside of your site, always use target="_top" or target="_blank" to ensure that the page doesn’t appear to be part of your site.

Re: Need Help w/ iframe and TARGET _parent

Posted: Sun May 24, 2009 12:53 pm
by suburbangypsy
tasairis wrote:I don't know how (or even if it's possible) using this CoffeeCup thing - it certainly would be ideal - but you can put some JavaScript inside your thank you page that (a) checks if it is inside the top-level frame, and (b) makes itself so if it is not. It should be right at the top of the page so it gets executed immediately rather than after stuff has begun loading.

Code: Select all

<script type="text/javascript">
if (window != window.top) window.top.location.href = window.location.href;
</script>
Normally I frown on this sort of thing but I don't know of a better way. Maybe somebody else does...
Thanks I will give this a try and let you know how it works.

And straightman, thanks for sharing that. I understand how each of the targets work and where to use them, but in html. I don't know how to use them in the way in which I need to use the target in the php I have to work with :)

Re: Need Help w/ iframe and TARGET _parent

Posted: Sun May 24, 2009 12:59 pm
by suburbangypsy
Thank you tasairis it worked :) I appreciate it!