[Javascript] Strictly speaking (Was Javascript Detection)

Paul Novitski paul at juniperwebcraft.com
Wed Jan 3 12:51:30 CST 2007


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

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 extent to which it's cross-browser-compatible is another question.

I don't anticipate using document.write() in my own work (if only 
because I use XHTML), but strictly speaking I suppose it isn't any 
more egregious than using pre-written HTML template chunks to 
assemble pages server-side.

Paul 




More information about the Javascript mailing list