A. JavaScript Genealogy and Reference

Over the course of close to two decades, JavaScript has undergone transformations since its introduction as part of Netscape Navigator 2.0. This appendix briefly discusses the different versions of JavaScript and which browsers include which version of JavaScript.

You’ll also find a JavaScript object flowchart as well as a table listing most of the JavaScript objects up to and including ECMAScript Edition 3, along with their properties, methods, and event handlers.

JavaScript Versions

The scripting language that you think of as JavaScript has several different names (depending on whose product you have) and almost a dozen different versions. Besides JavaScript, there are also JScript and ECMAScript. Here’s a guide to which version does what.

Netscape’s JavaScript

The first version of JavaScript, originally called LiveScript, was released in Netscape Navigator 2.0. Netscape intended LiveScript to be a way to extend the capabilities of browsers and to allow Web designers to add some interactivity to their sites. The JavaScript version in Navigator 2.0 was JavaScript 1.0.

Along with Navigator 3.0 came JavaScript 1.1, which added support for images, arrays, Java applets, and plug-ins, among many other changes.

With the release of Navigator 4.0 (also known as Netscape Communicator), JavaScript 1.2 was born, with more enhancements and refinements. Netscape 4.5 later shipped with JavaScript 1.3. JavaScript 1.4 was server-side only, and Netscape 6 introduced JavaScript 1.5.

Current versions of JavaScript are developed by the open-source Mozilla project, mainly for the benefit of its Firefox browser. Firefox (and its spinoffs, such as Camino for Mac OS X) fully supports ECMAScript-262 Edition 3, with some support for ECMA-Script-262 Edition 5 (see below).

At press time for this book, the current version of JavaScript is 1.8.5, which is shipping with Firefox 4 (as seen in Table A.1).

Table A.1. Netscape/Mozilla JavaScript Versions

Image

Microsoft’s JScript

As is so often the case, Microsoft implemented JavaScript in its own fashion, which is not always compatible with the Netscape version. Called JScript version 1, the Microsoft version of JavaScript was more-or-less compatible with JavaScript 1.0; there were some differences. Naturally, JScript appears only in Windows and versions of Microsoft Internet Explorer (MSIE).

On Windows, there was also a JScript version 2 (somewhat comparable to JavaScript 1.1) for Windows 95/NT that came with upgraded versions of MSIE 3.02 and later. Not all versions of MSIE 3.02 had JScript 2.0. If you happen to have one of these oldies, you can tell what version of JScript you have installed by searching your disk for jscript.dll. Get the file’s properties, and click the Version tab. If the file version does not begin with at least 2, you’ve still got the original.

On the Macintosh, MSIE 3.0 had no JScript, but version 3.01 did. That included JScript 1.0, but not the identical version as on Windows; there were differences between the Mac and Windows versions of JScript (for example, the Mac version supported the Image object for mouse rollovers, while the Windows JScript 1.0 did not). In 2003, Microsoft discontinued MSIE for Mac, ending official support in 2005.

Confused yet? You’re in good company. But wait, there’s more: JScript 3.0 was roughly equivalent to JavaScript 1.2, and JScript 5.x was roughly equivalent to JavaScript 1.5. Some versions of Windows are also associated with particular JScript versions, as JScript is one of the scripting languages that can be used to script Windows itself. Table A.2 helps you identify which version of JScript you have, depending on which version of IE and Windows you’re running.

Table A.2. JScript Versions

Image

AOL

Which versions of JavaScript did AOL browsers support? Given that AOL owned Netscape, you might guess that it shipped with that browser, but you’d be wrong, unless you’re talking about AOL for Mac OS X. For contractual reasons, AOL used Microsoft’s Internet Explorer. Table A.3 shows which browsers shipped with which versions of AOL.

Table A.3. AOL/MS IE Browser Chart

Image

According to AOL, the Mac (for Mac OS 9 and earlier) and 16-bit PC versions came with MSIE embedded into the client, but 32-bit PC versions since AOL version 3 could use whatever version of MSIE was on the user’s system. Consequently, these folks may have had anything from MSIE 3 to MSIE 6 or later installed. AOL for Mac OS X used Netscape technology to provide an embedded browser, which from the JavaScript standpoint was functionally equivalent to Netscape 7.

ECMAScript

In 1996, Web developers began to complain that Netscape was going in one direction with JavaScript, and Microsoft in a somewhat-compatible but different direction with JScript. Nobody likes to have to code pages to handle different dialects of JavaScript, or have their code work in one browser but not another. Developers wanted a standard. So Netscape went to an international standards body called ECMA and submitted the JavaScript language specification to it, and Microsoft threw in its own comments and suggestions. ECMA did whatever it is that standards bodies do and in June of 1997 produced a standard called ECMA-262 (also known as ECMAScript, a term that just dances off the tongue). This standard closely resembled JavaScript 1.1 but (sigh) was not exactly the same; subsequent versions rectified this problem. If you’re interested in reading the official ECMAScript specification, you can download it from www.ecma-international.org. Look for the Standards link and then follow it to the ECMA-262 specification.

ECMAScript has also had several versions since 1997: most importantly, Edition 3 was released in December 1999 and Edition 5 in December 2009 (Edition 4 was never completed, and it was finally abandoned). The current crop of browsers have full support for Edition 3 (roughly comparable to JavaScript 1.5) and are slowly adding in compliance with Edition 5. It’s important to note that ECMAScript is now driving the standards process; all current browser makers have the goal of making their implementations ECMAScript-compliant.

So as long as you write ECMAScript-compatible code, it should run just fine under browsers as far back as MSIE 4 and Netscape Navigator 6. But you should always test your code with different browsers, platforms, and versions just to be sure.

WebKit-based browsers (including Apple’s Safari and Google’s Chrome) are recent enough to have always supported ECMAScript.

Object Flowchart

Throughout this book, we’ve primarily used DOM scripting, relying on looking for particular ids versus particular objects. It’s simply easier to use getElementByID() and access the element you want directly, rather than descending the object tree, as with document.form.button.radio. We recommend that you use DOM scripting in your code, as well.

If you want information about what objects are available to you, check out (for instance) the Firefox DOM Inspector Image. While not everything is cross-browser, it will give you a number of places to start.

Image

Image With the Firefox DOM Inspector, you can see precisely how the browser sees your code. Other browsers have their own equivalents to the DOM Inspector.

For older browsers, however, those options aren’t available, and you need to know what properties exist and how they all fit together, and that’s where this section fits in, as a reference to the older method of doing things.

JavaScript objects are connected together in a particular order, which you can think of in terms of an organization chart. The primary object in JavaScript is the current window, and all other software objects flow from that window Image. This order of objects is often called the JavaScript object hierarchy, but that name is just a tad too self-important for this book.

Image

Image

Image

Image

The Big Object Table

No JavaScript book is complete without the whopping big table of JavaScript objects, along with their associated properties, methods, and event handlers (check Chapter 1 for definitions of these terms).

Table A.4 covers most of the JavaScript objects in the language up through and including ECMAScript Edition 3. We’ve omitted a few very obscure objects, as well as some older objects from earlier versions that have been superseded by new or extended objects.

Table A.4. JavaScript Object Table

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.59.145