JavaScript Bible (3rd Edition) Support Center
Corrections & Updates
- CD-ROM: The index.htm page that provides a collapsible outline-style table of contents for the CD-ROM listings requires that cookies be enabled in your browser. The code for the outliner is explained in Chapter 50, which is entirely on the CD-ROM (the publisher ran out of trees).
- Page 3: "URL" is the acronym for "Uniform Resource Locator".
- Page 59: The second sentence of the last paragraph should begin: Do not type a carriage return after the "=" sign....
- Page 65:
Instructions in the sidebar about testing evaluations in the JavaScript type-in page need slight modification to work with the new JavaScript Console window that appears in Navigator 4.07 and later. If you declare a variable in the type-in field, it seems to disappear from memory after the first time it is used in a subsequent statement. This is too bad, because the old way was much handier.
In any case, you can still test simple evaluations here. To follow the same sequence of thought in the example at the bottom of the sidebar, you have to declare the variables twice. Thus, enter the following statements one at a time and watch for results in the upper frame:
var myAge = 45
var yourAge = myAge - 15
myAge - yourAgevar myAge = 45
var yourAge = myAge - 15
myAge > yourAge - Page 68: The last word of the first sentence should be "number".
- Page 78: A </HEAD> tag is missing from Listing 7-2 right after the script.
- Page 95: The first sentence of the second paragraph should read: "A button in the page invokes the subWrite() function."
- Page 100:
The code excerpt in the lower half of the page is missing an equal sign (=) in the third line. The conditional expression requires the equality comparison operator (==), not the equal operator (=) as shown:
if (form.elements[i].type == "text") { - Page 105: In the first paragraph of the Select Object section, the reference to Figure 9-1 should read Figure 8-1
- Page 106: The third OPTION element value in Listing 9-4 should be "policies.html" if it is going to navigate anywhere.
- Page 116:
In the discussion of the indexOf() method, I must have experienced a mental lapse. A statement in the second full paragraph is wrong, as is the code example that supports it. The paragraph and example should read:
Two strings are involved with this method, the shorter one and the longer one. The longer string is the one that appears in the reference to the left of the method name; the shorter string is inserted as a parameter to the indexOf() method. To demonstrate the method in action, the following fragment looks to see if the user is running Windows:
var isWindows = false
if (navigator.userAgent.indexOf("Win") != -1) {
isWindows = true
} - Page 117:
An extra left parenthesis graces the second statement of the script fragment in the middle of the page. The statement should be:
var excerpt = stringA.substring(stringA.indexOf(" ") + 1, stringA.length) - Page 118:
The statement about raising numbers to a power of 10 would be better served with the following example:
var result = Math.pow(value1, 10)
The second parameter of the Math.pow() method is the power to which you want to raise the value of the first parameter. - Page 118:
As reader Paul Rubin points out, the script fragments on this page and on page 576 about random numbers give less than random results. The fix is simple, however:
newDieValue = Math.floor(Math.random() * 6) + 1 - Page 122: The listing in question #3 is missing the </FORM> tag right before the </BODY> tag.
- Page 129: In Listing 11-1, the first statement of the goNext() function should be the same as the first statement of the goPrev() function below it: var currOffset = parseInt(parent.currTitle). And for sake of consistent style, there should be a space between the < symbol and the 5.
- Page 130: In Listing 11-2, the second <FORM> tag should obviously be </FORM>.
- Page 131: The </BODY> tag is missing from Listing 11-3.
- Page 131: In the code listing at the beginning of the Exercises, the SRC attribute value has two periods where only one belongs.
- Page 136: See extensive notes below about Listing 12-2.
- Page 157: The URLs in Listing 13-2 don't match the text. The listing file on the CD-ROM does match. See also Listing 13-2 below.
- Page 162: The deeply nested statement in the second SCRIPT tag of Listing 13-5 has an extra space between forms[0]. and janeButton. In a lot of places, JavaScript doesn't care about extra spaces, but dot-delimited references cannot have any blank spaces in them.
- Page 169: In the middle of the page is an incorrect pointer to a figure. The clause should read: "..., just like the model shown in Figure 14-1."
- Page 173:
The javascript: pseudo-URL at the end of Listing 14-2 should not have quotes around the expression:
"javascript:parent.blank()" - Page 187: The compatibility chart at the top of the page should show only one checkmark:for Navigator 4.
- Page 191-2: For the content of the textarea element to be included in the mail message, you must assign a value to the textarea's NAME attribute, as shown in the code for the following item.
- Page 191-2:
Unlike Navigator 3/4, Internet Explorer 4 doesn't let you turn off script error dialog boxes by setting window.onerror to null. You can accomplish the same behavior with the following statements:
window.onerror = doNothing
function doNothing() {return true}If you are toggling between error messages on and off (as in Listing 14-9), you can build the above into the whole listing, as follows:
Error Dialog Control