Home Page -> DOM Tutorials -> Dynamic Text -> A Philosophical Interlude

A Philosophical Interlude

Before proceeding to the last example of dynamic text, there's an issue that we need to address. Those of you who have been using MicrosoftTM®© Internet ExplorerTM®© to do dynamic HTML are probably asking:

“Why do I need to go to all this trouble with nodes and children? All I need to do in Internet Explorer is modify the innerText or innerHTML property to get the same effect.”

Two reasons, and these are personal opinions, by the way, so take them for what they're worth.

  1. The innerText and innerHTML properties are Microsoft only and non-standard. I prefer to stick with standards that are agreed upon by the World Wide Web Consortium, because I know they'll work in any browser, on any platform, that conforms to those standards. This will become important in the future, when PDAs (Personal Digital Assistants) and “web tablets” start to become popular. The smaller ones may not have the memory capacity or speed to handle all the varieties of non-standard extensions that have been made to HTML; the trend appears to be that these devices will be standards-compliant.
  2. The very name innerHTML implies that it is tied to HTML. The Document Object Model, however, is generic. It applies not only to HTML documents, but also to XML documents. The knowledge acquired in maniuplating the DOM with HTML will be immediately transferable to this new up-and-coming technology.

End of sermon. Now, on to an example that shows the power of being able to use the DOM to dynamically modify a document.

  The gloss() function  Index A Complex Example