scottandrew.com

Noteworthy

You're currently viewing a very old version of this website. Follow me to the latest version.

-->

Scripting For The 6.0 Browsers

By Scott Andrew LePera
Revised January 27, 2002 | Printer-friendly version

Granted, Netscape 6 is far from perfect. But with its great support of DOM and CSS, it's a big step in the right direction. Hopefully it'll be the first in a line of popular, successful browsers that will be enthusiastically adopted by the web surfing public and make our lives as developers that much easier.

So what does that mean to us as scripting folk? Plenty, because the structure of the DOM exposes new powerful methods which allow you access and manipulate the elements of any document. This goes beyond DHTML and its <div> tags; it's comprehensive control over every page element via JavaScript.

With the DOM scripting methods you can:

- Create new elements on the fly. No more using document.write to insert HTML and CSS into your page, no more object constructors. The DOM allows you to create whole elements out of thin air.
- Grab all the tags of the document, or grab the text without grabbing the tag text.
- Insert new text, and change or remove text from any element without resorting to innerHTML or document.write().
- Move whole parts of the document around, or remove parts as fragments and work with them.
- And the best part: all of these new methods should work in any DOM compliant browser. No more browser sniffing. No need to build different versions of the same page for different browsers. One common set of scripting techniques is all that's needed.

This article is meant to be a brief, non-technical introduction to DOM scripting, with a focus on Netscape 6. Hardcore spec-heads (huh?) will want to check out the W3C's specifications on DOM and CSS for in-depth, white-papery techie jargon.

Excited yet? Let's look at this DOM thingy.

» Next Lesson: New Pieces Of The Puzzle