I was wondering if is it possible to prevent a form in iframe submitting to it's _parent page and force it to submit to iframe instead?
Please see my example below:
Content of page 1
<iframe src="http://server-b/form.html" width="450" height="500">
<p>Your browser does not support iframes.</p>
<form action="http://server-a/landing.cgi" target="_parent">
<input type="hidden" name="field1" value="val1" />
<input type="submit" value="Submit" />
Could you give a name to the iframe, and give that name to the target attribute? No scripting required, or needed even.
Hi Paul, many thanks for your reply.
Unfortunately I have no control over http://server-b/form.html
I can only manage http://server-a/...
So my idea was to use 'onbeforeunload' or similar to solve this problem. Not sure how this could be exactly done though.
onbeforeunload only allow you to show a message to the user, where they can choose to stay on the page or allow the new page to load.
For an example, see: onbeforeunload Demo
I don't think that web browsers allow you to have the control that you seem to need, over an iframe from another domain.