home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

JavaScript: The Definitive GuideJavaScript: The Definitive GuideSearch this book

1.3. Client-Side JavaScript

When a JavaScript interpreter is embedded in a web browser, the result is client-side JavaScript. This is by far the most common variant of JavaScript; when most people refer to JavaScript, they usually mean client-side JavaScript. This book documents client-side JavaScript, along with the core JavaScript language that client-side JavaScript incorporates.

We'll discuss client-side JavaScript and its capabilities in much more detail later in this chapter. In brief, though, client-side JavaScript combines the scripting ability of a JavaScript interpreter with the document object model (DOM) defined by a web browser. These two distinct technologies combine in a synergistic way, so the result is greater than the sum of its parts: client-side JavaScript enables executable content to be distributed over the Web and is at the heart of a new generation of Dynamic HTML (DHTML) documents.

Just as the ECMA-262 specification defined a standard version of the core JavaScript language, the World Wide Web Consortium (W3C) has published a DOM specification (or recommendation) that standardizes the features a browser must support in its DOM. We'll learn much more about this standard in Chapter 17, Chapter 18, and Chapter 19. Although the W3C DOM standard is not yet as well supported as it could be, it is supported well enough that web developers can start writing JavaScript code that relies on it.

Table 1-2 shows the core language version and DOM capabilities supported by various browser versions from Netscape and Microsoft. Note that the versions of Internet Explorer listed in the table refer to the Windows version of that browser. The capabilities of Macintosh versions of IE often vary (sometimes significantly) from the same-numbered versions for Windows. Also, bear in mind that IE allows the JScript interpreter to be upgraded independently of the browser itself, so it is possible to encounter an installation of IE that supports a version of the language greater than that shown here.

Table 1-2. Client-side JavaScript features by browser



DOM capabilities

Netscape 2

JavaScript 1.0

Form manipulation

Netscape 3

JavaScript 1.1

Image rollovers

Netscape 4

JavaScript 1.2

DHTML with Layers

Netscape 4.5

JavaScript 1.3

DHTML with Layers

Netscape 6 / Mozilla

JavaScript 1.5

Substantial support for W3C DOM standard; support for Layers discontinued

IE 3

JScript 1.0/2.0

Form manipulation

IE 4

JScript 3.0

Image rollovers; DHTML with document.all[]

IE 5

JScript 5.0

DHTML with document.all[]

IE 5.5

JScript 5.5

Partial support for W3C DOM standard

IE 6

JScript 5.5

Partial support for W3C DOM standard; lacks support for W3C DOM event model

The differences and incompatibilities between Netscape's and Microsoft's client-side versions of JavaScript are much greater than the differences between their respective implementations of the core language. However, both browsers do agree upon a large subset of client-side JavaScript features. For lack of better names, versions of client-side JavaScript are sometimes referred to by the version of the core language on which they are based. Thus, in client-side contexts the term "JavaScript 1.2" refers to the version of client-side JavaScript supported by Netscape 4 and Internet Explorer 4. When I use core-language version numbers to refer to client-side versions of JavaScript, I am referring to the compatible subset of features supported by both Netscape and Internet Explorer. When I discuss client-side features specific to one browser or the other, I refer to the browser by name and version number.

Note that Netscape and Internet Explorer are not the only browsers that support client-side JavaScript. For example, Opera (http://www.opera.com) supports client-side JavaScript as well. However, since Netscape and Internet Explorer have the vast majority of market share, they are the only browsers discussed explicitly in this book. Client-side JavaScript implementations in other browsers should conform fairly closely to the implementations in these two browsers.

Similarly, JavaScript is not the only programming language that can be embedded within a web browser. For example, Internet Explorer supports a language known as VBScript, a variant of Microsoft's Visual Basic language that provides many of the same features as JavaScript but can be used only with Microsoft browsers. Also, the HTML 4.0 specification uses the Tcl programming language as an example of an embedded scripting language in its discussion of the HTML <script> tag. While there are no mainstream browsers that support Tcl for this purpose, there is no reason that a browser could not easily support this language.

Previous editions of this book have covered Netscape browsers more thoroughly than Microsoft browsers. The reason for this bias was that Netscape was the inventor of JavaScript and (for a time, at least) held the dominant position in the web-browser market. This bias toward Netscape has declined in each subsequent edition of the book, and the current edition is heavily focused on standards, such as ECMAScript and the W3C DOM, rather than on particular browsers. Nevertheless, readers may find that some of the original bias toward Netscape comes through in the material that remains from older editions.

Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.