Form submit to iframe on new page
I have a form which开发者_Go百科 submits to an iframe, This works fine if you are on a page with the iframe.
I want to be able to have the form on any page and when submit is pressed load a page and send the submit to the iframe
e.g.
- On page "article.php" and press submit
- Open page "results.php" and
- Send post data from form clicked in "article.php" to iframe "DataHere" on "results.php"
Thanks in advance
You could try detecting if the frame exists when the form is submitted and if it does not, reload the whole page and generate the iFrame.
If you need a hand checkout http://www.java-scripts.net/javascripts/Check-Frames-Page-Script.phtml
If you are able to comfortably sanitize your initial POST
data to avoid XSS, you could create an intermediate page for your iframe destination that does your POST
for you:
- On page
article.php
with<form action="results.php">
, press submit. results.php
validates that the input isn't XSS, and renders with a<iframe src="negotiator.php?my=form&data=here"></iframe>
negotiator.php
takes the query string arguments (and runs the same sanitizing asresults.php
) andPOST
s them to your intended url.- Your results will load in the iframe.
It's pretty important that you make sure your input isn't insane. If your form requires arbitrary text, punctuation, and special characters, this is not safe for you.
精彩评论