Form submission with an IFRAME target

J

James Howe

I have a web page which has a form for the purpose of uploading a file
to a server. The way our page is written, I need to have the form
submit to a hidden IFRAME. I need the IFRAME to get the response from
the submission action. When my page is originally loaded, we execute
some javascript to create a hidden IFRAME within the document as
follows:

this.hiddenFrame = document.createElement("IFRAME");
this.hiddenFrame.style.visibility = "hidden";
this.hiddenFrame.setAttribute("id","exchangerClient");
this.hiddenFrame.setAttribute("name","exchangerClient");
this.hiddenFrame.setAttribute("src", "");
document.body.appendChild(this.hiddenFrame);

The HTML in the web page also has a form defined as follows:

<form action="/fileUpload"
enctype="multipart/form-data" method="post"
target="exchangerClient">
<input name="file" size="50" style="height: 25px" type="file" />
<input style="height: 25px" type="submit" value="Upload File" />
</form>

The idea is that when the user hits the 'Upload File' button, the form
would be submitted to the IFRAME (target="exchangerClient"). The
/fileUpload servlet would be invoked and the result returned from the
servlet would become the new document for the IFRAME.

When I display the page using Mozilla, Firefox or Opera 7.51, the page
behaves exactly as expected. My servlet gets called, the file gets
uploaded and the result makes it's way back to the IFRAME all without
visibly changing the page that the user is viewing. In IE6, this
isn't happening. The file is uploaded, but instead of the browser
staying on the same page with the result coming back to my hidden
IFRAME, a new window is opened with the URL of the action (e.g.
http://xx.xx.xx.xx/fileUpload) and displays the results returned from
the file upload servlet.

Am I just encountering a bug in IE, or is this an incompatibility
between IE and other browsers? Is there a reasonable workaround to
this problem (short of recommending that my users use a different
browser?)

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top