Pherdnut said:
First of all, the forms object is a part of the BOM.
No, `forms' is the name of a property of the DOM host object referred to by
`document', which is defined by the respective language-independent DOM
(Document Object Model) API. In particular, nowadays this object or its
prototype implement the HTMLDocument interface of W3C DOM Level 2 HTML which
defines a `forms' attribute (in the IDL, not to be confused with a markup
attribute) for which the implementation SHOULD implement the HTMLCollection
interface (at least four widely distributed implementations actually do that).
There is no such thing as document.divs[3] for instance.
That depends on the runtime environment, in particular on the layout engine
and its DOM implementation, and on the document that is represented by the
current view's document tree. But your statement is actually unrelated to
your earlier assertion anyway, thus cannot provide the proof for the latter.
In fact, for historical reasons dating back to Netscape Navigator 2.0 and
its JavaScript 1.0 implementation, there *is* a document.divs[3] property in
many DOM implementations (AFAIK including that of MSHTML, Gecko, Apple
WebKit, KHTML, Opera, and Netscape 4.x) if `divs' is the value of a HTML
`form' element's `name' attribute and that element contains at least four
form controls (e.g., `input' elements). That property would hold a
true-value, a reference to the DOM object representing the fourth control
within `<form ...>...</form>' in the source code.
(document.forms["divs"].elements[3] would the be proper, less error-prone,
backwards-compatible and standards-compliant referencing, of course.)
Another possibility to achieve this would be a successful, though naturally
error-prone, write access to augment the host object referred to by
`document' with a user-defined property named `divs', and this property
referring to an object having a property named `3':
document.divs = {"3": 42};
window.alert(document.divs[3]);
Or please consider this: By slight modification of your example, there is a
true-value document.all.divs[3] property in all MSHTML-based browsers, in an
HTML document that has at least four elements with `divs' for the value of
their `name' attribute, respectively. But if the layout engine used is not
MSHTML, or the document type is not (recognized as) HTML, there is no
guarantee that this is going to work. So there is _not_ (only) a (single)
"BOM". (A test case is readily available: Go to
<
http://www.google.com/preferences>
and enter
javascript:window.alert(document.all.lr[3].value);
in the address/location bar after the former has been fully loaded. If I'm
not mistaken, the alert message box should say `lang_be', for Belarusian,
everywhere where this is supported, and throw a ReferenceError(-like)
exception otherwise. It should also be supported in Firefox 3.5.1 [I tested
positive with Iceweasel], with a console warning, only because the document
is rendered in Quirks Mode due to the missing DOCTYPE declaration; other,
especially older, versions of Firefox would differ as compatibility with
MSHTML did not have that high a priority back then.)
So the first correction used the BOM and then went long with
additional stuff from the DOM.
Nonsense.
And by BOM I mean Browser Object Model.
Whereas the DOM that it is defined by instead, is both an application- and
language-inpendent API. The used layout engine, the (recognized) document
type, and the used rendering mode matter instead.
I'm afraid you don't know what you are talking about, probably being
considerably mislead by authors of books or libraries not/no longer to be
recommended.
Provably, and proved here (also numerous times before), it doesn't.
Instead, it has turned out to be necessary to distinguish between the
specified programming language, ECMAScript, and its Editions; the
implementations of that language (e.g. JavaScript, JScript) and their
versions; the application-independent, language-independent, layout-engine-
and layout-mode-dependent DOM (which nowadays implements, for example,
several interfaces of the W3C DOM API); the public browser API (that I have
come to generalize under the term AOM, Application Object Model; which
provides, for example, the (still-proprietary) host-defined `window'
property of the ECMAScript Global Object); and external APIs, whereas each
API provides an ECMAScript binding. In fact, this is an important
distinction that especially many book and library authors have yet to fully
understand, and to make in their books and libraries.
See also said:
and I find I prefer it for dealing with forms for some reason.
"Some reason" is hardly sufficient a reason. A "belly feeling" about a
technology or a technique alone does not exactly promote understanding of
it, as you should see by now, and if not yet, after having read below.
I think because form elements are so incredibly weakly spec'd
Such as in the W3C HTML 4.01 Specification or the W3C DOM Level 2 HTML
Specification? I shall assume, in your favor, that to have ended up with
this assessment you have been relying on Flanagan, Goodman, Resig, all of
them, or the like, for far too long.
<
http://www.w3.org/TR/html401/interact/forms.html#h-17.3>
<
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-40002357>
that I prefer to think of them as junk that comes from the OS
The OS does not even enter into any of this.
(which they typically are)
That MSHTML uses "windowed controls" (objects that have a window handle,
HWND) from the Win32 API for rendering some elements, especially form
controls (with the known disadvantages of that), is no indication at all
that (X)HTML `form' *elements* would "typically" have to do with the OS.
To begin with, "windowed controls" are never used for rendering (X)HTML
`form' *elements* by MSHTML.
rather than things that behave like proper DOM objects whose
presentation can be fully controlled through CSS properties. I'm not
sure they got updated for IDs but name attributes, which I avoid, can
be used to call the form elements by name.
That is gibberish. Please get yourself informed before further (mis-)parroting.
<
http://jibbering.com/faq/>
PointedEars