can anyone think of browser where this script would make sense

P

pantagruel

Hi,

The following script fragment is in an application I need to work
with:

var theForm = document.forms['Form1'];
if (!theForm) {
theForm = document.Form1;
}

which does not make much sense to me. The application is basically IE
only I guess, can anyone think of some version of IE in which this
would be sensible?
 
T

Thomas 'PointedEars' Lahn

pantagruel said:
The following script fragment is in an application I need to work with:

var theForm = document.forms['Form1'];
if (!theForm) {
theForm = document.Form1;
}

which does not make much sense to me. The application is basically IE
only I guess, can anyone think of some version of IE in which this
would be sensible?

Apparently the author of the code is assuming and trying to work around an
incompatibility between W3C DOM Level 2 and "DOM Level 0" (here: the MSHTML
3/4 DOM) where none exists.

Exposing this obvious a flaw in this basic field of client-side DOM
scripting, the code of the whole "application" should only be used with
extreme caution.


PointedEars
 
P

pantagruel

pantagruel said:
The following script fragment is in an application I need to work with:
var theForm = document.forms['Form1'];
if (!theForm) {
theForm = document.Form1;
}
which does not make much sense to me. The application is basically IE
only I guess, can anyone think of some version of IE in which this
would be sensible?

Apparently the author of the code is assuming and trying to work around an
incompatibility between W3C DOM Level 2 and "DOM Level 0" (here: the MSHTML
3/4 DOM) where none exists.

Exposing this obvious a flaw in this basic field of client-side DOM
scripting, the code of the whole "application" should only be used with
extreme caution.

PointedEars

oh believe me, the code of the application is getting a thorough
scouring.
But what incompatibility do you think is being assumed (I'm wondering
why anyone would assume this incompatibility?)

Cheers,
Bryan Rasmussen
 
T

Thomas 'PointedEars' Lahn

pantagruel said:
pantagruel said:
The following script fragment is in an application I need to work with:
var theForm = document.forms['Form1'];
if (!theForm) {
theForm = document.Form1;
}
which does not make much sense to me. The application is basically IE
only I guess, can anyone think of some version of IE in which this
would be sensible?
Apparently the author of the code is assuming and trying to work around an
incompatibility between W3C DOM Level 2 and "DOM Level 0" (here: the MSHTML
3/4 DOM) where none exists.
[...]

[...]
But what incompatibility do you think is being assumed (I'm wondering
why anyone would assume this incompatibility?)

It should have been obvious to you when looking at the source code and then
reading my explanation. The author's incorrect assumption is that there
could be a DOM where document.forms['Form1'] was not supported but
document.Form1 was. HTMLDocument::forms is a collection that is specified
in W3C DOM Level 2 HTML, but it originates from DOM Level 0's document.forms
collection and the aforementioned interface is implemented so. Therefore
there is no good reason for providing a fallback using the all-proprietary
("DOM Level 0") referencing with the `if' and within the block statement.

http://www.w3.org/TR/DOM-Level-2-HTML/


PointedEars
 
P

pantagruel

It should have been obvious to you when looking at the source code and then
reading my explanation. The author's incorrect assumption is that there
could be a DOM where document.forms['Form1'] was not supported but
document.Form1 was.
That's what I meant. I couldn't figure out any reason why anyone would
make that assumption. It just seems an extremely strange assumption
for this guy just to make. Your further explanation does give me a
reason why he might assume that though - although not a good reason. I
would have expected anyone that made this assumption to have at least
tested it at any rate.

Thanks for your help.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top