[Javascript] Strictly speaking (Was Javascript Detection)

Matt Warden mwarden at gmail.com
Wed Jan 3 13:05:47 CST 2007

On 1/3/07, Paul Novitski <paul at juniperwebcraft.com> wrote:
> At 1/3/2007 06:31 AM, Matt Warden wrote:
> >I find DOM manipulations to be elegant, once you wrap your ahead
> >around the fact that this is *not* markup anymore, but rather an
> >active document, represented by a tree structure.
> I've always considered document.write() to be sloppy, DOM-less
> coding, however the manual does say:
> "The text you write is parsed into the document's structure model. In
> the example above, the h1 element becomes a node in the document."
> http://developer.mozilla.org/en/docs/DOM:document.write

I'm not sure how else it would work. I can't think through my head how
the markup itself could just be inserted as a text node but somehow
still function as part of the document.

> This means that document.write() [according to the book] plays nicely
> with the DOM and doesn't dodge around it.  The onus is on the
> programmer to feed it well-formed HTML, but then of course that's
> always the case.

The point is more that HTML is just one serialization of a document.
Once the markup is unserialized back into a document tree, it doesn't
make sense to manipulate it with arguments that are serialized. It's
really just the developer being lazy and avoiding the need to think
about the document as a tree and not text/markup, which goes back to
my original point. Not to mention that your javascript must be aware
of how the document is serialized in the first place.

Matt Warden
Cleveland, OH, USA

This email proudly and graciously contributes to entropy.

More information about the Javascript mailing list