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.
}
)
got chopped off. That right angle brace closes the subWrite()
function. See also Notes, below.
document.forms[0].selectName.selectedIndex
<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.
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 == "") {
value
property will be examined only for text-type input elements (if the first condition fails, the second one is not evaluated).
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);
}
width
property is missing from the bottom of the leftmost column in the top table.
nodeValue
property of an element type of node returns a null
value."
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.
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.
onbeforepaste
's Example section should be
to Listing 15-44.
oncut
's Example section should be
to Listing 15-44.
top
attribute in Table 16-3 controls the Vertical position.
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.
<frame>
tag.
alt
property should read:document.myIMG.alt = "Fred\'s face";
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.
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.
setSelection()
. As you can see in Listing 23-4, the actual name of the function is doSelection()
.
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.
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.
</form>
tag right above the </body>
tag.
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.
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.
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 anonload
oronunload
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 theonload
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 otherwindow.open()
timing problems that necessitated theonload
handler in the tutorial, and also allows subwindows to be opened without violating popup blocking settings.