Ban IE from the Planet

Ok, the mistake was mine, but let’s faced it, IE (Internet Exploer) is not even close to be ready to the Web 2.0. I was doing a common Javascript with form submission, so I had a javascript code like this:

function submit_form(){
document.form1.action = ‘postHandler.php’;
document.form1.enctype = ‘multipart/form-data’; = ‘theHiddenIframe’;

My form code was like this:

<form id=”form1″ name=”form1″>
<input type=”button” value=”upload” onclick=”form_submit()” />
<input type=”file” value=”” name=”uploadfile” />

On Firefox it will work perfectly, but on IE it will send the file as string.  What was happening is that on IE you must set the enctype on the form tag because it will not accept the tag to be set dynamically.

Easy fix and now everything is working, but stop and think about this a second: Now with AJAX and new Javascript resources why would you set every attribute of a form tag, besides the name and the id?

Anyway, if you have gone through the same problem this might be one solution.

Have fun.

Update: I got this from a friend of mine. You can set the enctype dinamicly on IE, but you need to use:

document.form1.encoding = ‘multipart/form-data’;

About mcloide

Making things simpler, just check: View all posts by mcloide

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: