Skip to main content
Inspiring
November 22, 2011
Answered

Submit PHP form in iFrame, and go to _parent

  • November 22, 2011
  • 2 replies
  • 2828 views

Hi,

So I have a PHP form that is quite long. It is rendered in an iFrame in another html page (for css reason).

I have set the dimensions of the iFrame to be as long as the form itself, as I believe that have a scroll bar that goes down "the middle of the page" (as it were - i.e. down the side of the iFrame) as well as down the edge of the page (the actualy parent page) is confusing for the user, and ugly.

However, by the time the user gets to the bottom of the form, they are quite a long way down the "_parent" page. So, when they click 'Submit', and the $insertGoTo = "/thanku.html" executes, they don't actually see the Thank You page, because it renders in the iFrame that they're at the very bottom of. The only way they see it is if they then choose to scroll up to the top of the page.

Is there any way of getting the parent page to default back to the top at this point?

Failing that, is there anyway of getting the $insertGoTo command to GoTo the parent page instead of the iFrame?

Thank you.

This topic has been closed for replies.
Correct answer _AJD_TUS_

I got it: I put this at the top of my thanku.php page:

<script language="JavaSCript">

if (top.location != location) top.location.href = location.href;

</script>

This breaks the page out of the frame.

2 replies

_AJD_TUS_AuthorCorrect answer
Inspiring
January 24, 2012

I got it: I put this at the top of my thanku.php page:

<script language="JavaSCript">

if (top.location != location) top.location.href = location.href;

</script>

This breaks the page out of the frame.

_AJD_TUS_Author
Inspiring
November 24, 2011

Might make this easier to answer if you can see the page in question:

http://www.whataretheyreallylike.com/review.html

Your thoughts, please?

MurraySummers
Inspiring
November 26, 2011

Wouldn't it be simpler to work on the "css reason" for the form being in a IFrame so that you could integrate the IFrame page's code into the parent page?

What is that reason?