Re: FAQ Topic - What online resources are available? (2009-01-29)
- From: Garrett Smith <dhtmlkitchen@xxxxxxxxx>
- Date: Wed, 28 Jan 2009 20:37:08 -0800
Jorge wrote:
I'm going to review one of these.
//**********************************************************
An Inconvenient API: The Theory of the DOM:
<http://video.yahoo.com/video/play?vid=111582>
Interesting history.
That video mentions a strategy for not sending javascript to unsupported browsers.
He also advocates not including the required |type| attribute of a script tag and having the server send the mime type header. This results in the document being invalid. It will work, but the validation error will appear.
In general, it is a good idea to validate the document. Developers will often complain that it doesn't work, when they've gone and used invalid HTML.
Collections:
document.anchors
...
document.stylesheets
That is a mistake. It should be: document.styleSheets.
| The earliest view of the dom was as um a collection of collections,
| and the through these collections you could get particular
| elements and modify them.
| These collections are still available in the browsers (um). They're
| not in any standard, but ah they're obsolete now. They're uh, as we'll
| see, more modern alternatives to all of these things. So these are
| pretty much irrelevant now. I recommend you not use them.
DOM 1 defined these, so they're in a standard. I don't understand why he recommends not to use these.
| Instead of using document.all, the w3c said: "Instead, we should use
| document.getElementById(id)" This has the advantage in that its
| longer and requires more typing.
LOL
| [getElementsByName] will return an Array of things which happen
| to have a name.
That's not correct. Instead, getElementsByName(name) returns a *NodeList* of *Elements* whose name matches the name argument. Except in IE < 8 which confuses ID and NAME (a common bug that most regulars are well aware of).
| Also, this particular tree [refers to diagram] is an Internet Explorer
| Tree. FIrefox will give you a different tree. Ah, and you might think
| that's uh, inconvenient, you may be right.
|
| The reason for that is uh, the w3c requires that the whitespace
| between there and there (points to nodes on html diagram) be captured
| in a text node and stuck in the tree, so, there'd be, the tree would
| be a lot hairier, because all that unnecessary whitespace would be
| trapped in the structure.
It's all good until the last sentence; the whitespace is necessary and not having it causes bugs in IE.
For example:
<div id='pre'>
<strong> hello! </strong>
</div>
If we want to see the whitespace, we can use:
document.getElementById('pre').style.whiteSpace = 'pre';
but if whitespace was dropped, as in IE, then it would not work.
All the time I have for now.
I can't recommend that.
--
comp.lang.javascript FAQ <URL: http://jibbering.com/faq/ >
.
- Follow-Ups:
- References:
- Prev by Date: Re: Get the number of Images of a web page
- Next by Date: Re: FAQ Topic - What books are recommended for javascript? (2009-01-28)
- Previous by thread: Re: FAQ Topic - What online resources are available? (2009-01-29)
- Next by thread: Re: FAQ Topic - What online resources are available? (2009-01-29)
- Index(es):
Relevant Pages
|