JavaScript Editor JavaScript Debugger     JavaScript Editor 

Team LiB
Previous Section Next Section

The Initial JavaScript Object Model

If you recall the history of JavaScript presented in Chapter 1, the primary purpose of the language at first was to check or manipulate the contents of forms before submitting them to server-side programs. Because of these modest goals, the initial JavaScript object model first introduced in Netscape 2 was rather limited and focused on the basic features of the browser and document. Figure 9-2 presents JavaScript’s initial object model that is pretty similar between Netscape 2 and Internet Explorer 3.

Click To expand
Figure 9-2: The initial JavaScript object model

You might be curious how the various objects shown in Figure 9-2 are related to JavaScript. Well, we’ve actually used them. For example, window defines the properties and methods associated with a browser window. When we have used the JavaScript statement


to create a small alert dialog, we actually invoked the alert() method of the Window object. In fact, we could have just as easily written:


to create the same window. Most of the time because we can infer that we are using the current Window object, it is generally omitted.

The containment hierarchy shown in Figure 9-2 should also make sense once you consider a statement like this:

window.document.write("<<strong>>Hi there from JavaScript!<</strong>>");

This should look like the familiar output statement used to write text to an HTML document. Once again we added in the prefix “window,” this time to show the hierarchy, as we tended to use just document.write() in our examples. You might be curious about what all the various objects shown in Figure 9-2 do, so in Table 9-1 we present a brief overview of the traditional browser object. As you can see, the bulk of the objects are contained within the Document object, so we’ll look at that one more closely now.

Table 9-1: Overview of Core Browser Objects




The object that relates to the current browser window.


An object that contains the various (X)HTML elements and text fragments that make up a document. In the traditional JavaScript object model, the Document object relates roughly to the <body> tag.


An array of the frames if the Window object contains any. Each frame in turn references another Window object that may also contain more frames.


An object that contains the current window's history list, namely, the collection of the various URLs visited by the user recently.


Contains the current location of the document being viewed in the form of a URL and its constituent pieces.


An object that describes the basic characteristics of the browser, notably its type and version.

Team LiB
Previous Section Next Section

JavaScript Editor JavaScript Debugger     JavaScript Editor