Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to submit a form from inside an iframe and have result be outside

I have been trying to have a small login widget that I embed within a static page inside an iframe allow someone to log into my site. The problem I get is that when the form posts it ends up appearing inside the iframe instead of as a full browser page.

I know it is possible to do this because https://www.salliemae.com/ employs the same strategy on their home page. They embed an iframe inside their static page that does all their logic for them. I have very similar javascript in that I call form.submit() when someone clicks. The only difference is that I use jQuery to catch the click event vs putting the onclick directly on the form element.

I have looked at their code in their calm.js and it seems to be doing a simple form.submit() as I do, but their page loads fully in the browser vs only in the iframe. I have looked around SO and not seen a similar post, so if I just missed it, please let me know.

like image 748
Scott Avatar asked Jan 25 '12 22:01

Scott


1 Answers

See target="_top" in the iframe's <form> tag. That tells the browser to load the response in the parent frame.

like image 152
Hamish Avatar answered Oct 14 '22 21:10

Hamish