I am Hack Sparrow
Captain of the Internets.

Form submission with iframe target opens in a new Window

Why is the form with target set to an iframe opening in a new window?

Quick answer

Give the iframe a name attribute.


This is the proper way of submitting a form through a named iframe.

<form action="/upload" method="post" enctype="multipart/form-data" target="uploader_iframe">
<input type="file" name="image" />
<input type="submit" />
<iframe id="uiframe" name="uploader_iframe">

Note: the target value of the form should be the name of the form NOT THE id! If you forget to give the iframe a name, the form submission will take place in a new window.

Make a Comment