By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,741 Members | 2,009 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,741 IT Pros & Developers. It's quick & easy.

Set Encoding Dynamically in IE6 Instead of Enctype

P: n/a
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.
Oct 3 '08 #1
Share this Question
Share on Google+
7 Replies


P: n/a
vunet <vu******@gmail.comwrites:
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));
}
};
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
Oct 3 '08 #2

P: n/a
vunet wrote:
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
<http://msdn.microsoft.com/en-us/library/ms533745(VS.85).aspxis true?
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.

<http://www.jibbering.com/faq/faq_notes/not_browser_detect.html#bdTop>
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
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Oct 3 '08 #3

P: n/a
Eric B. Bednarz wrote:
vunet <vu******@gmail.comwrites:
>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
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Oct 3 '08 #4

P: n/a

Do you mean to say that the opposite of what is said in
<http://msdn.microsoft.com/en-us/library/ms533745(VS.85).aspxis true?
There is a Warning on that page where it states that encoding should
be used instead of enctype when dynamically setting the multipart.
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.

<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.
>
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.

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.
>
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
* -- Richard Cornford, cljs, <f806at$ail$1$8300d...@news.demon.co.uk>
Oct 3 '08 #5

P: n/a
Thomas 'PointedEars' Lahn <Po*********@web.dewrites:
Eric B. Bednarz wrote:
>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?
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.
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
Oct 3 '08 #6

P: n/a
Eric B. Bednarz wrote:
Thomas 'PointedEars' Lahn <Po*********@web.dewrites:
>Eric B. Bednarz wrote:
>>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?

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
--
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>
Oct 5 '08 #7

P: n/a
On Oct 5, 7:39*am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
Eric B. Bednarz wrote:
Thomas 'PointedEars' Lahn <PointedE...@web.dewrites:
Eric B. Bednarz wrote:
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?
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
--
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?
Oct 6 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.