2

I use iFrames to display secure forms within our websites so that I can have the forms stored on a secure server but the websites themselves don't have to be.

Once the user submits the forms and the data has been put in the database I would like to have them redirected to a thank you page on the website.

I have tried

header('LOCATION: http://www.site.net');

and

echo '<META HTTP-EQUIV="Refresh" Content="0; URL="http://www.site.net">';

I have also searched through this site and can't find an answer to this.

Thank you in advance for any help you can offer.

4
  • So you want to change the "outer" site, when the user submits a form in the iframe? Commented Jun 6, 2014 at 8:31
  • I would suggest checking out this stack article :) stackoverflow.com/questions/954454/… Commented Jun 6, 2014 at 8:32
  • Yes Luigi that's correct Commented Jun 6, 2014 at 8:36
  • does your form has target to iframe? Commented Jun 6, 2014 at 8:42

1 Answer 1

3

You need to tell the parent window (iframe container) to do a redirection using the DOM object window.top

Javascript:

window.top.location.href = "http://www.site.net/saythankyou"; 
Sign up to request clarification or add additional context in comments.

4 Comments

If the user got javascript disabled browser won't it cause troubles I mean he won't be redirected.
The user must have javascript enabled, there is no way to get the parent window in the server side, remember an iframe is an additional instance of the browser. You should take control with javascript.
Thanks for your answer. Didn't know it was the only solution we had.
I agree, there is no way around this with Javascript disabled. User experience could be improved by showing a "thanks, please click to return to main site" when javascript is disabled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.