Download (direct link):
72 Part I: Building Killer Web Pages for Fun and Profit
In This Chapter
^ Understanding how object models work ^ Exploring properties and methods ^ Adding text to a Web page dynamically ^ Positioning text on a Web page ^ Changing Web page appearance on-the-fly ^ Getting familiar with Netscape Navigator’s object model ^ Getting familiar with Internet Explorer’s object model
Part I: Building Killer Web Pages for Fun and Profit
Object Models Always Pose Nude
Here’s a real-world example of an object model. If I tell you my friend Ralph works in an office, you might reasonably assume that Ralph has a boss, a few co-workers, sits at a desk, and does some kind of work. How do you know all this without me telling you? Because you’ve seen or heard of other offices; perhaps you’ve even worked in one yourself. In other words, you’re familiar with the office model — so even though you don’t know anything about Ralph’s particular office just yet, you can correctly guess a great deal. In fact, all I have to do is fill in a few specific details (the names of Ralph’s co-workers, what kind of work he does, and so on) for you to have a complete picture of how Ralph spends his day.
The beauty of an object model is that it helps people communicate clearly and efficiently.
The DOM performs this oh-so-useful task by describing
All the objects that go into making up a Web page, such as forms, links, images, buttons, and text.
The descriptive properties associated with each of the DOM objects.
For example, an image object can be associated with specific properties describing its height and width.
The behaviors, or methods, associated with each of the DOM objects. For example, the window object supports a method called alert() that allows you to display an alert message on a Web page.
Chapter 4: Getting Acquainted with the Document Object Model
Conceptually, the DOM is the same whether you’re viewing a Web page in Internet Explorer, Netscape Navigator, or another browser entirely. In practice, however, the versions of the DOM implemented for Internet Explorer and Netscape Navigator differ — and you must pay attention to these differences or risk creating scripts that some users can’t view. See “Browser Object Models” later in this chapter for details.
In nerd-talk, an object is a software representation of a real-world thing. Theoretically, any person, place, thing, or can be represented as an object.