admin管理员组文章数量:1221396
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 / 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.
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.
Share Improve this question asked Jan 25, 2012 at 22:14 ScottScott 17k16 gold badges82 silver badges122 bronze badges 2- If the request crosses domains, ports or protocols, browsers shoot it down. Google XSS for more information. – Blender Commented Jan 25, 2012 at 22:18
- in my case (and the salliemae example above) they are both on the same domain. So for the question, how do I do it assuming both are on the same domain? Salliemae only has the lower level domain in common, they are on different subdomains (www. vs. login.) – Scott Commented Jan 25, 2012 at 22:20
2 Answers
Reset to default 16See target="_top"
in the iframe's <form>
tag. That tells the browser to load the response in the parent frame.
If you do not ajax the content, you just add target="_top"
to the form, otherwise you will have to use window.open(*serialisedurl*,"_top")
本文标签: javascriptHow to submit a form from inside an iframe and have result be outsideStack Overflow
版权声明:本文标题:javascript - How to submit a form from inside an iframe and have result be outside - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739290038a2156650.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论