JavaScript Bible (5th Edition) Support Center

Corrections & Updates

Corrections or changed information for the first printing (corrections will be incorporated into subsequent printings, so not all of the following items may apply to your copy of the book.). Page numbers marked "BC" are from the Bonus Chapters on the CD-ROM.

  • Page 93. At the bottom of the page (in Listing 8-3), a line containing a single right angle brace (}) got chopped off. That right angle brace closes the subWrite() function. See also Notes, below.
  • Page 105. The first code line example is missing an "s". It should be:

       document.forms[0].selectName.selectedIndex

  • Page 108. In the fourth line up from the bottom of Listing 9-5, the right angle bracket is missing at the end of the <input> tag that starts on the line above. That tag and the one following it should be:

    <input type="button" name="process" value="Process Request..." onclick="processData(this.form)"></p>

    If you're a bit puzzled by the behavior of this example, here's an explanation of the programming logic behind what you experience. When you enter a new song title into the text box and click the "Process Request" button, the button click action is interrupted by the onchange event handler of the text box (clicking outside of the text box or hitting the Tab key triggers the text field's onchange event handler before anything really happens outside of the text box). In other words, the button doesn't really get clicked because the onchange alert dialog comes up first. That's why you have to click it what seems to be a second time to get the combined song/Beatle verification. If you don't change the text in the field, your click of the button occurs without interruption, and the combined verification takes place.

  • Page 109. Listing 9-6 needs to include a test inside the repeat loop for text-type input elements to prevent the loop from reading the value properties of other types of input elements. The if clause should read as follows:

       if (form.elements[i].type == "text" && form.elements[i].value == "") {

    This way, the value property will be examined only for text-type input elements (if the first condition fails, the second one is not evaluated).
  • Pages 132-3. The four images referred to at the bottom of page 132 and shown in Listing 12-1 are not in the Chapter 12 folder as described. But you can get them from inside the Listings/Chap16 folder (on the CD-ROM), where they are used for other examples.
  • Pages 136-7. You can download the images for the rollover example in Listing 12-2.
  • Page 165. Figure 14-1 (the lowest common denominator DOM hierarchy) is missing the concentric rectangles mentioned in the text. Here is my original art submitted to the publisher's artists:

    Figure 14-01

  • Page 167. The third paragraph of "Object Methods" incorrectly suggests that the code listing that follows is supported in IE4 or later. But the window.outerWidth and window.outerHeight properties are not supported in IE. Instead, use the window.resizeTo() method, which is supported by a wide range of browsers. Here is the revised fullScreen() function:

       function fullScreen() {
          this.moveTo(0,0);
          this.resizeTo(screen.availWidth, screen.availHeight);
       }

  • Page 168. In the section "Event handlers as methods," the last paragraphs, beginning with "A byproduct of and event..." to the end of that section should have been deleted from this edition. The information there was true for some early browser versions, but is no longer applicable.
  • Page 195. The caption for Figure 14-4 is missing a "v" in front of the first word of the second line.
  • Page 204. The width property is missing from the bottom of the leftmost column in the top table.
  • Page 239. For the sake of clarity, the second sentence of the last paragraph should read: "The nodeValue property of an element type of node returns a null value."
  • Page 240. The second paragraph of the discussion of offsetHeight and offsetWidth properties has the point about standards-compatible vs. quirks mode mixed up (of course, the whole subject and even Microsoft docs are mixed up, so what else is new?). The following statements assume that you specify style sheet rules for the width and/or height of an inline (non-positioned) element, and then use the corresponding "offset" properties to obtain dimensional data about the rendered element. In quirks mode (the default behavior of IE6 and the only behavior of versions before IE6), the properties measure the dimensions of only the element's content; border, padding, and margin style settings do not influence the measurement (yet when the element is an <img> element, for instance, borders do get counted—go figure!).

    In standards-compatible mode (using DOCTYPE switching in IE6 and the default behavior of Mozilla-based browsers and Safari), the property measurements do include padding and borders, but not margins.

  • Page 302. Compatibility for the normalize() method should include WinIE6 and MacIE5. Be aware, however, that the method does not work correctly in WinIE6, and one reader avoids it because it crashes his IE6. I don't have problems in MacIE5, however. Safari 1.2 also supports the method.
  • Page 326. The listing pointer in onbeforepaste's Example section should be to Listing 15-44.
  • Page 331. The listing pointer at the end of oncut's Example section should be to Listing 15-44.
  • Page 420. Some of the superscripts in the left column of Table 16-3 didn't superscript, making the numbers look like they're part of the attribute names. None of the attribute names ends in a number, so whenever you see a trailing number, it's a superscript pointing to the notes at the end of the table on page 421.
  • Page 421. The top attribute in Table 16-3 controls the Vertical position.
  • Page 454. Delete the onload event handler from the <body> tag of Listing 16-42. The call to the init() function is made from the getPrefsData() function in Listing 16-41.
  • Page 460. The first line of code on the page incorrectly shows a closing frame tag, which is forbidden in HTML. The frame specification is entirely within the attributes of the <frame> tag.
  • Pages 462 & 469. In the paragraph introducing the second batch of syntax formats for each command, the third word should be or.
  • Page 472. Function parameters shown throughout the scripts of Listing 16-46 are not used in the functions. You can remove them safely (they don't do any harm if left in, but they're unneeded baggage). You can also experiment by revising the functions to be more generalizable, so that calls to the functions pass the references indicated in the printed version.
  • Page 606. The second code example for the alt property should read:
    document.myIMG.alt = "Fred\'s face";
  • Pages 616-7. A reader reports that Listing 20-4 didn't swap images when running under Mozilla 1.7.5 and Windows XP. Although I couldn't verify this, I found it to be OK on MacOS and the reader confirmed that it worked on a Unix variant he tried. Additional reports of problems welcome (provide specific browser version number and OS).
  • Page 618. In the discussion of the useMap property, the value should point to the map element, as, indeed, shown in Listing 20-7. It's the map element that contains all the info about the client-side image map, which may consist of one or more area elements nested within.
  • Page 621. The property listing for the area object mentions the noHref property, but it somehow was omitted from the descriptive part. This is a Boolean property, which your scripts can use to disable or enable a particular area element. To disable the area, set the noHref property to true. Compatibility is NN6, IE4, and DOM1.
  • Page 684. In the last paragraph there are several references to a function called setSelection(). As you can see in Listing 23-4, the actual name of the function is doSelection().
  • Page 685. Around the middle of the page in Listing 23-4, the long parameter to setTimeout() has a superfluous space after the lonely period string between formName and fldName. The purpose of the statement is to recreate a reference to a form control, and we all know that there are no spaces in JavaScript object references.
  • Page 711. The IE-only add() and remove() methods belong to the options array object, and not individual option element objects, as indicated. The working example in Listing 24-2 demonstrates the correct usage.
  • Page 1131. The answer to #5 (starting on page 1130) is missing the closing tag for the form. Insert the </form> tag right above the </body> tag.
  • Pages BC87-93. A single object representing a MIME type should technically be referred to as a MimeType object; likewise, a plug-in should be referred to as a Plugin object. I've been using first-letter lowercase representations for years in my books because scripts refer to single objects by way of the mimeTypes and plugins arrays. The only time you'd possibly refer to the initial-capital versions would be if (in Mozilla) you wanted to add a prototype property or method to the base object (e.g., Plugin.prototype.brandName = "";). Therefore, the Quick Reference (page 1111) should list the MimeType and Plugin objects at the tops of their respective boxes. Moreover, the refresh() method belongs to the navigator.plugins array, not an individual Plugin object. The example at the bottom of page BC-92 is correct.
  • Pages BC184-9. After the book went to press, Apple released Safari 1.2, which surprisingly and happily includes full support for the XMLHttpRequest object as devised by Microsoft and implemented by Mozilla. It works great in Safari, and examples from Chapters 52 (OPML version) and 57 run fine in Safari 1.2 without any modification. I wrote an additional article with a different example for the Apple Developer Connection web site.
  • Pages BC287. The URL provided for the W3C Markup Validation Service should be validator.w3.org.
  • Updated Listings

    • Listing 15-33. For some reason, the file for this example on the CD-ROM went through an uppercase-ectomy, rendering the scripts inoperable. Refer to the printed version on page 324, which is correct.
    • Chapter 52 (XML Outline) and 57 (Transforming XML Data). Although these sample applications show up in the Listings index page as not working in Safari, they do work in Safari 1.2, which added support for the XMLHttpRequest object.

    Notes

    • Popup Blocking. If you use a browser that has popup window blocking turned on, some examples won't work as expected. Popup blocking typically prevents the window.open() method from being invoked in an onload or onunload event handler -- and this blockage is a good thing. A few examples in the book, notably Listing 8-3, are wired to open a window via the onload event handler. I don't normally recommend this, but for the sake of simplicity in an early tutorial example, that's what I had to use. Later in the book, you learn how to work around other window.open() timing problems that necessitated the onload handler in the tutorial, and also allows subwindows to be opened without violating popup blocking settings.