Set Encoding Dynamically in IE6 Instead of Enctype

V

vunet

My form uploads files by submitting them to hidden IFrame. I set
enctype "multipart/form-data" dynamically. This works great everywhere
but IE6.
I discovered that in IE6 I need to set encoding instead of enctype. So
I built the following:


if(document.all) form.encoding = "multipart/form-data";
else form.enctype = "multipart/form-data";
form.submit();
if(document.all) form.encoding = "";
else form.enctype = "";

But after submitting, form encoding property cannot be found. How do I
handle this process correctly?
Thanks.
 
E

Eric B. Bednarz

vunet said:
I discovered that in IE6 I need to set encoding instead of enctype. So
I built the following:
if(document.all) […]

For educational purposes, I would start with doing the following in
Opera 9, Safari 3 and Firefox 1+ (the latter in backcompat mode):

window.onload = function () {
if (!document.all) {
alert(Array.prototype.slice.call(document.all));
}
};
 
T

Thomas 'PointedEars' Lahn

vunet said:
My form uploads files by submitting them to hidden IFrame. I set
enctype "multipart/form-data" dynamically. This works great everywhere
but IE6.
I discovered that in IE6 I need to set encoding instead of enctype.

Do you mean to say that the opposite of what is said in
So I built the following:

if(document.all) form.encoding = "multipart/form-data";
else form.enctype = "multipart/form-data";

That's double nonsense because document.all is supported by MSHTML 4 and
above, partially by Gecko 1.8.1 and above in Quirks Mode, by Opera, KHTML,
and WebKit.

form.submit();
if(document.all) form.encoding = "";
else form.enctype = "";

After the form was submitted, the `form' reference is invalid because
another resource was navigated to (unless there is a 204 No Content response).
But after submitting, form encoding property cannot be found. How do I
handle this process correctly?

Do not use object inference but perform feature tests, and do not use `form'
after `form.submit()'. It is not necessary to reset anything anyway.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Eric said:
vunet said:
I discovered that in IE6 I need to set encoding instead of enctype. So
I built the following:

if(document.all) […]

For educational purposes, I would start with doing the following in
Opera 9, Safari 3 and Firefox 1+ (the latter in backcompat mode):

window.onload = function () {
if (!document.all) {
alert(Array.prototype.slice.call(document.all));
}
};

What educational purpose should this example serve -- how *not* to do things?

1. `window.onload' is unnecessarily proprietary, given the existence of
the `onload' attribute of the `body' element.

2. As often discussed before, the first argument of Array.prototype.slice()
is *not* specified as being optional: ToInteger(undefined) is NaN which
cannot be used in the algorithm (ES3F, 15.4.4.10).

4. ToInteger(undefined) == NaN [9.4]
1. ToNumber(undefined) == NaN [9.3]
5. If Result(4) is negative, use max((Result(3)+Result(4)),0);
else use min(Result(4),Result(3)).
min(NaN, ...)

3. What educational purpose should slicing a *false*-value serve?

4. "Whether the slice function can be applied successfully to a host
object is implementation-dependent." (ibid.)


PointedEars
 
V

vunet

Do you mean to say that the opposite of what is said in
<http://msdn.microsoft.com/en-us/library/ms533745(VS.85).aspx> is true?

There is a Warning on that page where it states that encoding should
be used instead of enctype when dynamically setting the multipart.
That's double nonsense because document.all is supported by MSHTML 4 and
above, partially by Gecko 1.8.1 and above in Quirks Mode, by Opera, KHTML,
and WebKit.

<http://www.jibbering.com/faq/faq_notes/not_browser_detect.html#bdTop>

Thanks for this. In fact I added that for demo purposes but normally I
determine IE6 with document.all && !window.XMLHttpRequest. If this is
still conflicting with some non-IE browsers, please suggest your way.
After the form was submitted, the `form' reference is invalid because
another resource was navigated to (unless there is a 204 No Content response).


Do not use object inference but perform feature tests, and do not use `form'
after `form.submit()'.  It is not necessary to reset anything anyway.


I see what you say but I need to submit images separately to IFrame
and then the form without multipart after. Does it mean that I am
stuck here? Should I create additional forms to handle this?
Thanks.
 
E

Eric B. Bednarz

Thomas 'PointedEars' Lahn said:
Eric B. Bednarz wrote:

What educational purpose should this example serve -- how *not* to do things?

It illustrates in the mentioned browsers (some people prefer that over
unnecessarily verbose quotations and citations) that this kind of
feature detection does not tell you anything by compactly alerting the
contents of the document.all collection although it is true that
document.all coerces to false.
2. As often discussed before, the first argument of Array.prototype.slice()
is *not* specified as being optional:

It does not matter in this context, but that was indeed a rather stupid
mistake.

Beyond that you are so argumentative for its own sake that it is silly,
at best.
 
T

Thomas 'PointedEars' Lahn

Eric said:
It illustrates in the mentioned browsers (some people prefer that over
unnecessarily verbose quotations and citations) that this kind of
feature detection does not tell you anything by compactly alerting the
contents of the document.all collection although it is true that
document.all coerces to false.

Ahh, right. My bad. (There are better ways to show this, though.)


PointedEars
 
V

vunet

Ahh, right.  My bad.  (There are better ways to show this, though.)

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
  -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

I had a question here: how to handle dynamic setting of encoding to
the form in IE6 and keep a reference to the form after it is submitted?
 

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

Members online

Forum statistics

Threads
474,263
Messages
2,571,062
Members
48,769
Latest member
Clifft

Latest Threads

Top