The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".
The following errata were submitted by our customers and approved as valid errors by the author or editor.
Version |
Location |
Description |
Submitted By |
Date submitted |
Date corrected |
|
?
3.2. The Assignment Statement |
The text says:
However, with the following, where variables are lined up with commas between them, the first variable is set and the second ends up undefined:
var nValue1,nValue2 = 3; // nValue2 is undefined
But, nValue2 will be equal to 3 and nValue1 will be undefined. So it should read:
However, with the following, where variables are lined up with commas between them, the first variable is set and the first ends up undefined:
var nValue1,nValue2 = 3; // nValue1 is undefined
This:
var nValue1,nValue2 = 3; // nValue2 is undefined
document.writeln("<p>" + nValue1 + "</p>");
document.writeln("<p>" + nValue2 + "</p>");
Prints out this in Firefox and IE:
undefined
3
Note from the Author or Editor: Should read:
However, with the following, where variables are lined up with commas between them, the second variable is set and the first ends up undefined:
var nValue1,nValue2 = 3; // nValue1 is undefined
|
Steve Miller |
Jan 15, 2009 |
|
|
?
3.4.1. The Equality and Identity (String Equality) Operators |
Code snippet used "If" that should be "if":
var nValue = 3.0;
var sValue = "3.0";
If (nValue == sValue) ...
Should be:
var nValue = 3.0;
var sValue = "3.0";
if (nValue == sValue) ...
Note from the Author or Editor: If (nValue == sValue) ...
should be
if (nValue == sValue) ...
|
Steve Miller |
Jan 15, 2009 |
|
|
?
4.3. Regular Expressions and RegExp |
After Example 4-7 there is the following paragraph:
The regular expression pattern used in Example 4-7 is a very handy expression to keep in mind. If you want to replace all occurrences of spaces in a string with dashes, regardless of what's following the spaces, use the pattern /\s+\g in the replace method, passing in the hyphen as the replacement character.
/\s+\g should be /\s+/g
|
Steve Miller |
Jan 15, 2009 |
|
|
?
Example 8-5. Accessing text-based input fields from JavaScript |
This line returns a null object in Firefox 3.0.5:
document.getElementById("text4").value=strResults;
It works in IE7.
This appears work in both browsers:
document.getElementById("someForm").text4.value=strResults;
Note from the Author or Editor: The textarea in example 8-5 should have an id attribute assigned "text4", as well as name to use getElementById. The example in the examples file for the book have the id attribute and work correctly.
|
Steve Miller |
Jan 22, 2009 |
|
|
?
9.5. Adding and Controlling Timers |
The following code:
Var tmOut = setInterval("functionName", 5000);
Should be:
var tmOut = setInterval("functionName", 5000);
Also, this is a minor note. Above this code is the syntax for the setTimeout function:
var tmOut = setTimeout(func, 5000,"param1",param2,...,paramn);
The double quotes around the 1st param1 appear to me to be unnecessary and confusing. I think it would read better as:
var tmOut = setTimeout(func, 5000, param1, param2, ..., paramn);
Thanks :)
Steve
Note from the Author or Editor: The double quotes around param1 in first code snippet are not necessary
first word of third code snippet should read var, not Var
|
Steve Miller |
Jan 23, 2009 |
|
|
?
9.6.3. The navigator Object |
I'm using Firefox version 3.0.5 and the text states:
"The mimeTypes collection consists of mimeType objects, which have properties of description, type, and plugin."
The words "description", "type", and "plugin" are bolded to denote the names of the properties.
I checked using Firebug and the mimeType objects don't have a "plugin" property. There is a property named "enabledPlugin".
Thanks :)
Steve
Note from the Author or Editor: The mimeType object has an enabledPlugin property, not a plugin property
|
Steve Miller |
Jan 23, 2009 |
|
|
?
Example 12-4. Element positioning and movement with fly-ins |
The follow style generates an error in Firefox 3.0.6:
#div2 {
background-color: #ff0;
color: #;
The error:
Warning: Expected color but found '#'. Error in parsing value for property 'color'. Declaration dropped.
Source File: http://burningbird.net/lj2/ch12-04.html
Line: 30
The Safari version has an extra 's' after the div3. This isn't on the on-line example:
<div id="div3">
<p>Red block that has fixed positioning.</p>s
Note from the Author or Editor: Example 12-4, page 272, CSS setting for #div2 should be:
color: #000;
Not
color: #;
|
Steve Miller |
Feb 09, 2009 |
|
|
?
Example 15-3. Client application modified to work with an XML response |
If you select California and them Missouri, California's cities remain in the options for Missouri.
You can solve this by clearing the options in getCities() like so:
// access city selection
var citySelection = document.getElementById("citySelection");
citySelection.options.length = 0;
Note from the Author or Editor: In example 15-3, add the following:
citySelection.options.length = 0;
After the line of code that reads:
var citySelection = document.getElementById("citySelection");
|
Steve Miller |
Feb 17, 2009 |
|
Printed |
Page 4
1st paragraph |
"When you're visiting web pages and curious as to how..."
s/b
"When you're visiting web pages and ARE curious as to how..."
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 4
Note |
EMCA-262
should be
ECMA-262
6) 2nd sentence under "First Look at..." heading;
"All you need to do, at a minimum, is include HTML..."
s/b [bc of parallel construction]
"All you need to do, at a minimum, is TO include HTML..."
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
4
1st paragraph |
"When you're visiting web pages and curious as to how..."
s/b
"When you're visiting web pages and ARE curious as to how..."
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
4
Note |
EMCA-262
should be
ECMA-262
6) 2nd sentence under "First Look at..." heading;
"All you need to do, at a minimum, is include HTML..."
s/b [bc of parallel construction]
"All you need to do, at a minimum, is TO include HTML..."
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 7
Example 1-1 |
<body onload="hello();"> is an error as the function hello is undefined. The example runs quite well without the onload="hello(); as the popup is generated as soon as the script is executed.
It's a bit discouraging to find such a fundamental error in the first example!
|
Anonymous |
Aug 28, 2008 |
|
Printed |
Page 7
2nd sentence in 1st paragraph |
"If it doesn't, chances are that JavaScript is disabled in the browser, or,..., Javascript isn't
supported."
s/b [bc of parallel construction]
"If it doesn't, chances are that JavaScript is disabled in the browser, or,..., THAT Javascript
isn't supported."
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 7
Example 1-1 |
Body tag in Example 1-1 should read:
<body>
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
7
2nd sentence in 1st paragraph |
"If it doesn't, chances are that JavaScript is disabled in the browser, or,..., Javascript isn't
supported."
s/b [bc of parallel construction]
"If it doesn't, chances are that JavaScript is disabled in the browser, or,..., THAT Javascript
isn't supported."
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
7
Example 1-1 |
Body tag in Example 1-1 should read:
<body>
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 9
Example 1-2 |
The line
document..writeln(msg);
should be:
document.writeln(msg);
|
Anonymous |
|
Jan 01, 2007 |
Printed |
Page 11
Insert new section, just before the section titled "JavaScript Files" |
header: Quirks versus Standard Mode and DOCTYPEs
In the examples, the DOCTYPE used is XHTML 1.0 Transitional, even though all of the examples in the book
are served as HTML, and with an .html extension. Which DOCTYPE used can influence how the page markup,
CSS, and even JavaScript are interpreted. It's all based on a concept called 'quirks' mode, as compared
to standards or strict mode.
As browsers improve their support for markup and CSS standards, they also have to maintain backwards
compatibility with pages created for older browsers. One way to do this is to render a page in such a
way that it supports the browser's earlier 'quirky' behavior, in a mode called 'quirks mode'. Depending
on the DOCTYPE, either a browser will render the page using an earlier interpretation of a specification,
such as Internet Explorer's infamous CSS box model bug; or it will render it according to a
standards-based viewpoint.
The XHTML 1.0 Transitional DOCTYPE triggers standards mode for most browsers, even if the page itself
isn't meant to be interpreted as an XHTML document. To actually be served up as XHTML, it needs to be
passed to the browser with the XHTML MIME type, typically triggered if the extension is .xhtml. However,
other modifications need to be made to the page, such as ensuring it is valid XHTML, and also modifying
the opening html tag to include the tag namespace, the vocabulary where all the elements are defined:
<html xmlns="http://www.w3.org/1999/xhtml">
The HTML 4.01 strict DOCTYPE can also trigger standards mode for most browsers, but I don't use it
because the page won't validate if proper XML markup is used. For example, the meta tag in most of the
examples uses a closed tag format:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
This is invalid with the HTML 4.01 strict DOCTYPE. For that DOCTYPE, we need to use:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Though HTML 4.01 is standard and still supported, we want to get into the habit of using proper XHTML
markup as much as possible, even if the pages are still served up as HTML. This means less work when we
are ready to make the step to serving pure XHTML documents, and eliminating all HTML.
I mentioned earlier about how the DOCTYPE can impact on JavaScript. Well, in actuality it's how the
document is served that can impact. Several of the examples use document.write or document.writeln. The
reason I use these is that the example modifies the page. Later in the book, I introduce the Document
Object Model (DOM) and demonstrate 'proper' methods of modifying the document. Until we reach that point,
though, and in those cases where an alert box doesn't work well, the example uses document.write.
Unfortunately, one of the drawbacks with using document.writeln is that it's not valid with a document
that's served as XHTML. In fact, it won't work.
The reason that documents rendered as XHTML don't allow document.write is that XHTML documents are
considered to be valid XHTML, and won't display unless they are. If we can modify the documents with
document.write, the browser has no way of knowing if the content being written to the page is valid or
not. We could introduce 'bad' markup, which would render the guarantee of validity with XHTML.
This same concern also exists with the use of innerHTML (which we'll look at later in the book). However,
most browser do support this rather important property, and some browsers even validate the content
being used to set innerHTML to ensure it's valid.
For the rest of the chapter, the XHTML 1.0 Transitional DOCTYPE is used to ensure standards mode.
Remember though that the namespace setting (http://www.w3.org/1999/xhtml), the extension (.xhtml), and
the presence or not of document.write can impact on the document actually being served as XHTML. In the
examples that can be downloaded for the book, multiple versions with different document types and
extensions are provided for a couple of the examples, to demonstrate the variations discussed in this
section. Each will have comments to discuss what changes were made so the document would serve correctly,
as well as validate.
|
Anonymous |
|
|
Printed |
Page 19
To validate, script section in Example 1-3 should be surrounded by |
a CDATA section, as demonstrated in Example 1-2.
|
Anonymous |
|
|
Printed |
Page 25
4th paragraph |
This chapter covers the the three basic...
should be
This chapter covers the three basic...
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
25
4th paragraph |
This chapter covers the the three basic...
should be
This chapter covers the three basic...
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 26
The reserved word 'public' is listed twice; disregard the second occurrence. |
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 26
var-ident should be var_ident |
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
26
The reserved word 'public' is listed twice; disregard the second occurrence. |
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
26
var-ident should be var_ident |
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 28
3rd example block |
The comment that reads,
// becomes 71
should be,
// becomes "71"
to indicate that the result is a string data type, rather than a number. (N.B. This syntax was used correctly on the preceding line.)
Note from the Author or Editor: Change third example on page 28, second line, to:
var strValueTwo = 4 + 3 + "1"; // becomes "71"
|
Jim Ward |
Nov 27, 2010 |
|
Printed |
Page 28
validate-name should be validate_name |
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 28
The sentence that reads, "Though you can use the $, number, or |
underscore to begin a variable, your best bet is to start with a letter."
should read
"Though you can use the $, letters, or underscore to begin a variable,
your best bet is to start with a letter."
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
28
validate-name should be validate_name |
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
28
The sentence that reads, "Though you can use the $, number, or |
underscore to begin a variable, your best bet is to start with a letter."
should read
"Though you can use the $, letters, or underscore to begin a variable,
your best bet is to start with a letter."
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 29
mid-page; The current link is |
http://dojotoolkit.org/developer/StyleGuide
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
29
mid-page; The current link is |
http://dojotoolkit.org/developer/StyleGuide
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 31
Last two code samples |
"embedded in the page" does not match code, which uses the string "embedded in page"
|
Anonymous |
|
|
Printed |
Page 31
2nd paragraph from page bottom |
Two problems here:
(1) The notation "2e31", which appears twice in the first sentence, is incorrect. This notation as written means "2 times 10 to the 31st power", clearly not the author's intent. Rather, this should read "2", followed by "31" written as a superscript in each of its two instances here.
(2) The upper range for the functions you reference is actually "2 to the 31st power minus one", 2**31-1, the integer representation of which is 2,147,483,647.
Note from the Author or Editor: Page 31 remove notation in second to last paragraph:
Though larger numbers are supported, some functions can only work with numbers in range of -2,147,483,648 to 2,147,483,648.
|
Jim Ward |
Nov 27, 2010 |
|
Printed |
Page 31
2nd paragraph, 2nd sentence |
"The first, global.js, concatenates it's own string, globally in globalPrint, to the message."
"globally in globalPrint" should be in fixed font to demonstrate it is a literal string
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 31
the second block of code, which begins with |
message += " globally in globalPrint";
Since the variable is undefined, this generates an error in Firefox 2.x
(though not necessarily other browsers, or earlier versions of Firefox).
To prevent, use:
if (typeof(message) != 'undefined') message += " globally in globalPrint";
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
31
2nd paragraph, 2nd sentence |
"The first, global.js, concatenates it's own string, globally in globalPrint, to the message."
"globally in globalPrint" should be in fixed font to demonstrate it is a literal string
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
31
the second block of code, which begins with |
message += " globally in globalPrint";
Since the variable is undefined, this generates an error in Firefox 2.x
(though not necessarily other browsers, or earlier versions of Firefox).
To prevent, use:
if (typeof(message) != 'undefined') message += " globally in globalPrint";
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 32
1st paragraph |
"Hi, you were here" does not match the string in the code, which is "also accessed in
global2Print"
|
Anonymous |
|
|
Printed |
Page 35
Example 1, in the file on O'Reilly's site (the print version is correct) |
burningbird,net
should be
burningbird.net
|
Anonymous |
|
|
Printed |
Page 35
3rd of 3 examples listed at the top of page |
In this set of examples that begins on page 34, sValue is set to the empty string. This evaluates to false in JavaScript, not true. See the 2nd paragraph of the author's own quote of Simon Willison later in the page.
Note from the Author or Editor: Commenter is correct.
Third example on page 35 change to:
if (sValue) // true if variable is both defined and given a value
|
Jim Ward |
Nov 27, 2010 |
|
Printed |
Page 36
1st text paragraph |
"...block in Example 2-1 is replaced..."
should be
"...block in Example 2-2 is replaced..."
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
36
1st text paragraph |
"...block in Example 2-1 is replaced..."
should be
"...block in Example 2-2 is replaced..."
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 38
|
Examples of floating point numbers in middle of page should read:
(to O'Reilly, note about superscript):
0.3555
144.006
-2.3
44.1(2) // note that the 2 should be typographed as superscript
19.5(e-2) (which is equivalent to 19.5(-2)) // note that the e-2 and -2
should be superscript
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
38
|
Examples of floating point numbers in middle of page should read:
(to O'Reilly, note about superscript):
0.3555
144.006
-2.3
44.1(2) // note that the 2 should be typographed as superscript
19.5(e-2) (which is equivalent to 19.5(-2)) // note that the e-2 and -2
should be superscript
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 39
|
Sentence that reads:
"You can convert strings or booleans to numbers..."
should read
"You can convert strings to numbers..."
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
39
|
Sentence that reads:
"You can convert strings or booleans to numbers..."
should read
"You can convert strings to numbers..."
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 40
1st paragraph under "Null and Undefined" |
more so then
should be
more so than
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
40
1st paragraph under "Null and Undefined" |
more so then
should be
more so than
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 41
1st line |
sValue has not not been delcared
should be
sValue has not been declared
|
Anonymous |
|
Jan 01, 2007 |
Printed |
Page 43
Question 4 |
hexidecimal
should be
hexadecimal
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
43
Question 4 |
hexidecimal
should be
hexadecimal
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 44
2nd code snippet at bottom of page |
var bValue = true; var sValue = "this is also true"
should end with a semi-colon, like -
var bValue = true; var sValue = "this is also true";
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
44
2nd code snippet at bottom of page |
var bValue = true; var sValue = "this is also true"
should end with a semi-colon, like -
var bValue = true; var sValue = "this is also true";
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 46
The sentence starting with |
"Usually, I should add,..."
should read
"Most complex JS libraries are 'usually' not more than a few hundred lines, because some of the newer
Ajax libraries can be quite large."
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
46
The sentence starting with |
"Usually, I should add,..."
should read
"Most complex JS libraries are 'usually' not more than a few hundred lines, because some of the newer Ajax
libraries can be quite large."
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 48
|
Sentence that reads:
" - Represents a negative value"
Should read
" - Changes sign of value
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
48
|
Sentence that reads:
" - Represents a negative value"
Should read
" - Changes sign of value
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 50
4th block of text |
we're typed out
should be
we've typed out
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 50
Under "Bitwise Operators" |
there is excellent Boolean algebra reference
should be
there is an excellent Boolean algebra reference
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 50
Code snippet |
nValue += 3.0;
should be
nValue += 30;
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
50
4th block of text |
we're typed out
should be
we've typed out
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
50
Under "Bitwise Operators" |
there is excellent Boolean algebra reference
should be
there is an excellent Boolean algebra reference
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
50
Code snippet |
nValue += 3.0;
should be
nValue += 30;
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 51
|
The code snipped mid-page should read:
var flag_A = 0x1;
var flag_B = 0x2;
var flag_C = 0x4;
var flag_D = 0x8;
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
51
|
The code snipped mid-page should read:
var flag_A = 0x1;
var flag_B = 0x2;
var flag_C = 0x4;
var flag_D = 0x8;
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 52
To validate, Example 3-1 needs a closing body tag. |
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
52
To validate, Example 3-1 needs a closing body tag. |
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 58
The code for the switch statement should be |
switch (stateCode) {
case 'OR' :
case 'MA' :
case 'WI' :
statePercentage = 0.5;
taxPercentage = 3.5;
break;
case 'MO' :
taxPercentage = 1.0;
statePercentage = 1.5;
break;
case 'CA' :
case 'NY' :
case 'VT' :
statePercentage = 2.6;
taxPercentage = 4.5;
break;
case 'TX' :
taxPercentage = 3.0;
break;
default :
taxPercentage = 2.0;
statePercentage = 2.3;
}
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 58
The line starting with |
"In this instance, the case values associated with the block are
separated from the others by commas, which means any of the three can
match."
should be
"In this instance, the case values all resolve to the same block, which
means any one of the three can match."
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
58
The code for the switch statement should be |
switch (stateCode) {
case 'OR' :
case 'MA' :
case 'WI' :
statePercentage = 0.5;
taxPercentage = 3.5;
break;
case 'MO' :
taxPercentage = 1.0;
statePercentage = 1.5;
break;
case 'CA' :
case 'NY' :
case 'VT' :
statePercentage = 2.6;
taxPercentage = 4.5;
break;
case 'TX' :
taxPercentage = 3.0;
break;
default :
taxPercentage = 2.0;
statePercentage = 2.3;
}
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
58
The line starting with |
"In this instance, the case values associated with the block are
separated from the others by commas, which means any of the three can
match."
should be
"In this instance, the case values all resolve to the same block, which
means any one of the three can match."
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 59
Delete the sentence |
It's identical in behavior to listing out the options, separated by commas.
|
Anonymous |
|
May 01, 2008 |
Other Digital Version |
59
Delete the sentence |
It's identical in behavior to listing out the options, separated by commas.
|
Anonymous |
|
May 01, 2008 |
Printed |
Page 60
Change following sentence |
In particular, the equality operator is implicitly used in the switch
statement, which means that both of the following cases are applicable
if the switch expression evaluates to "3.0":
to
In particular, the switch statement does not implicitly use an equality
operator, which means that an expression of 3.0 evaluates true for the
first case statement, false for the second:
|
Anonymous |
|
|
Printed |
Page 62
|
Code snippet should read:
if (sValue <= 2.0) // true
|
Anonymous |
|
|
Printed |
Page 63
general format of ternary operator is |
condition ? value if true : value if false;
|
Anonymous |
|
|
Printed |
Page 68
Example 3-8 |
eval ("document.writeln(document.." + docprop + ")");
should be
eval ("document.writeln(document." + docprop + ")");
|
Anonymous |
|
|
Printed |
Page 71
2nd line of sample code, halfway down |
holdAnwer
should be
holdAnswer
|
Anonymous |
|
|
Printed |
Page 75
Last Paragraph should read: "The substr method returns a substring |
given a starting location and length of string. (example)
(following example) The substring and slice methods return a substring
given a starting and ending index.
|
Anonymous |
|
|
Printed |
Page 78
2nd paragraph |
The following using the explicit option:
should be
The following uses the explicit option:
|
Anonymous |
|
|
Printed |
Page 78
All references to the regular expression '+s' and /+s/ should be |
replaced by
's+' and /s+/ respectively.
|
Anonymous |
|
|
Printed |
Page 85
|
Example that reads:
var newDt = new Date(1977,12,23);
should be
var newDt = new Date(1977,11,23);
|
Anonymous |
|
|
Printed |
Page 85
|
example of Date.UTC near the bottom that reads:
var numMs = Date.UTC(1977,16,24,30,30,30)
should read:
var numMs = Date.UTC(1977,11,24,19,30,30,30)
|
Anonymous |
|
|
Printed |
Page 86
|
Last line of example code in page should read:
<body> not </body>
Also, the element directly after "</head>" should be "<body"> (not
"</body>").
|
Anonymous |
|
|
Printed |
Page 93
Code snippet with |
var removed = fruitArray.splice(2,2,'melon,banana');
should be
var removed = fruitArray.splice(2,2,'melon','banana');
|
Anonymous |
|
|
Printed |
Page 93
In the second example block |
the letters in legnth are transposed, and should be "length".
|
Anonymous |
|
|
Printed |
Page 94
The line |
"The pop method removes the last element of the array, while the shift
returns the first element."
should read:
"The pop method removes the last element of the array, while the shift
removes the first element."
|
Anonymous |
|
|
Printed |
Page 94
|
second and third comments in Example 4-10 should read:
// use shift to shift items off the array
and then
// now, same with unshift
|
Anonymous |
|
|
Printed |
Page 95
The sentence |
The result of running this JavaScript is:
Should be
The result of running this JavaScript in our target browsers (all but IE 6.x and IE7, which don't return a
length when using unshift) is:
|
Anonymous |
|
|
Printed |
Page 95
Example 4-10 |
document.writeln("new length is " + fifoNewArray.length );i
should be
document.writeln("new length is " + fifoNewArray.length );
(delete the 'i' at end of line)
|
Anonymous |
|
|
Printed |
Page 101
Sentence beginning with |
"If a condition isn't met..."
Should be
"If a condition is met..."
|
Anonymous |
|
|
Printed |
Page 103
|
Code snippet that reads:
var func = (params) {
Should read
var fun = function(params) {
|
Anonymous |
|
|
Printed |
Page 105
|
Sentence that reads:
Returning to the Array methods, the filter method ensures that elements
are not added to any element...
Should read
Returning to the Array methods, the filter method ensures that elements
are not added to an array...
|
Anonymous |
|
|
Printed |
Page 125
|
The sentence that starts
"When the input field is clicked..."
should read
"When the second input field is clicked (the first loses focus)..."
|
Anonymous |
|
|
Printed |
Page 127
|
The sentence that starts
"This makes sense, when you consider that cascade means that the lowest..."
should read
"This makes sense, when you consider that cascade means the highest..."
|
Anonymous |
|
|
Printed |
Page 129
Example 6-7 |
add the following line as the first line in the function clickMe:
evnt = evnt ? evnt : window.event;
|
Anonymous |
|
|
Printed |
Page 133
Last sentence in the second paragraph |
The sentence
In fact, this is probably one of these most common reasons for triggering an event directly:
s/b
In fact, this is probably one of the most common reasons for triggering an event directly:
|
Anonymous |
|
|
Printed |
Page 135
The sentence that starts with |
"For the newer event systems, which use either the attachMethod or
addEventListener..."
Use
"For newer event systems, which use either the attachEvent or
addEventListener..."
|
Anonymous |
|
|
Printed |
Page 135
In code snippet |
document.formname.addEventListener("submit", formFunction. false);
The period should be a comma
|
Anonymous |
|
|
Printed |
Page 138
|
The reference to Example 4-9 should be Example 7-1
|
Anonymous |
|
|
Printed |
Page 138
Code snippet |
opts[opts.length] = new Option("Option Four", "Opt 4");
Should be
opts[opts.length] = new Option("Option Four", "Opt4");
|
Anonymous |
|
|
Printed |
Page 139
Example 7-2, line 11 (of the code) |
window.addEventListener("load",setupEvents1,false);
should be
window.addEventListener("load",setupEvents,false);
|
Anonymous |
|
|
Printed |
Page 142
Example 7-3, line 21 |
} else if (document.someForm..attachEvent) {
should be
} else if (document.someForm.attachEvent) {
|
Anonymous |
|
|
Printed |
Page 143
The sentence that starts with |
"Also in the example, DOM Level event handling..."
Should be
"Also in the example, DOM Level 2 event handling..."
|
Anonymous |
|
|
Printed |
Page 144
Example 7-4 |
Line:
var theEvent = evnt ? evnt : window.event;
Should be:
evnt ? evnt : window.event
|
Anonymous |
|
|
Printed |
Page 146
Middle of page |
You have this:
function validateField(evnt) {
var theEvent = evnt ? evnt : window.event;
var target = evnt.target ? evnt.target : evnt.srcElement;
var rgEx = /^\d{3}[-]?\d{2}[-]?\d{4}$/g;
var OK = rgEx.exec(target.value);
if (!OK) {
alert("not a ssn");
}
}
Which does not work in Internet Explorer because you are referencing to the wrong object on var target = evnt.target ? evnt.target : evnt.srcElement;
where evnt should be theEvent.
See below
function validateField(evnt) {
var theEvent = evnt ? evnt : window.event;
var theSrc = theEvent.target ? theEvent.target : theEvent.srcElement;
var rgEx = /^\d{3}[-]?\d{2}[-]?\d{4}$/g;
var OK = rgEx.exec(theSrc.value);
if (!OK) {
alert("not a ssn");
}
}
Can you please update the examples as well.
|
Anonymous |
Sep 11, 2008 |
|
Printed |
Page 153
numbered list 1/3 way down the page |
Item 1 is written as "Select element event". This should be "second element event". Neither "First" (in item 2) nor "Document" (in item 3) should be capitalized, in order to correspond with the example 7-4 code.
Note from the Author or Editor: Numbered list following code and first paragraph on page 153 change to
1. second element event
2. first document event
3. document event
|
Jim Ward |
Nov 27, 2010 |
|
Printed |
Page 175
Example 9-6 : 9th line |
<p><a href="" onclick="parent.frameb.location.replace"
should be
<p><a href="" onclick="parent.frameb.location.replace
No quote at the end of the line and the italic font should be removed.
|
Anonymous |
|
|
Printed |
Page 176
the sentence towards the bottom, |
"The frametwo page has a link to another page called noway.htm..."
should be:
"The frametwo page has a link to another page called frame2.htm..."
|
Anonymous |
|
|
Printed |
Page 181
2nd paragraph |
"color depths greater than the older eight pixels"
should be
"color depths greater than the older eight bits"
|
Anonymous |
|
|
Other Digital Version |
193
8.1.2 Canceling an Event. 3rd paragraph |
wrong method name
the text reads:
The returnValue property is equivalent to returning false explicitly in the function, and preventDefault prevents the default
behavior based on the object and the event. For instance, with a click event on a submit button, calling ---->stopPropagate<--- and
setting returnValue to false prevents the default form submission behavior.
I think instead, you need to chance name stopPropagate to stopPropagation
Note from the Author or Editor: Page 198 (print) para 1, change stopPropagate to stopPropagation
|
Anonymous |
Jan 24, 2010 |
|
Printed |
Page 199
the sentence that starts with |
"To add text, the createTextNode factory object..."
should read
"To add text, the createTextNode factory method..."
|
Anonymous |
|
|
Printed |
Page 199
An end tag for the HEAD element should be added before the opening |
|
Anonymous |
|
|
Printed |
Page 206
the sentence that starts with |
"In the application, when the nodeValue property is not null..."
should read
"In the application, when the nodeValue property is null..."
|
Anonymous |
|
|
Printed |
Page 206
function randomColor() |
Code should be used in randomColor to
check if the digit returned is single digit, and if it is, alter the
string to add a preceding zero, as in if (r.length == 1) r = "0" + r;
|
Anonymous |
|
|
Printed |
Page 218
the getDocumentById should be getElementById |
|
Anonymous |
|
|
Printed |
Page 227
In Example 227, change the following two lines |
opacity = opacity * 100;
img.style.filter = "alpha(opacity:"+opacity+")";
To
var opac = opacity * 100;
img.style.filter = "alpha(opacity:"+opac+")";
|
Anonymous |
|
|
Printed |
Page 229
Example 11-5 |
Move the following line, included in the setup function, outside the setup function:
document.onclick=changeOpacity;
And change the getOpacity function to:
if (this.obj.style.filter) {
var filterString = this.obj.style.filter;
var derivedVal =
filterString.substring(filterString.indexOf(':')+1,filterString.indexOf(')'));
return derivedVal / 100;
} else {
return this.obj.style.opacity;
}
|
Anonymous |
|
|
Printed |
Page 233
4th paragraph, code snippet |
"valueb".
should read:
"valueb",
|
Anonymous |
|
|
Printed |
Page 237
Example 11-7 |
Move the following line, included in the setup function, outside the setup function:
document.onclick=changeOpacity;
And change the getOpacity function to:
if (this.obj.style.filter) {
var filterString = this.obj.style.filter;
var derivedVal =
filterString.substring(filterString.indexOf(':')+1,filterString.indexOf(')'));
return derivedVal / 100;
} else {
return this.obj.style.opacity;
}
|
Anonymous |
|
|
Printed |
Page 246
3rd paragraph |
Replace window.getComputedStyle with currentStyle and getComputedStyle with window.getComputedStyle.
Instead of:
"It tests, first, whether window.getComputedStyle is supported, and if not, tests for getComputedStyle."
It should read:
"It tests, first, whether currentStyle is supported, and if not, tests for window.getComputedStyle"
|
Anonymous |
|
|
Printed |
Page 246
In Example 12-2 change the line |
return
document.defaultView.getComputedStyle(obj,null).getPropertyValue(cssprop);
to
return window.getComputedStyle(obj,null).getPropertyValue(cssprop);
|
Anonymous |
|
|
Printed |
Page 253
The second sentence in the page that has |
"...the top value, is greater than a value (200 + a value * the number of elements..."
should read
"...the top value, is greater than a value (100 + a value * the number of elements..."
|
Anonymous |
|
|
Printed |
Page 274
Add to the end of the paragraph at top of page, just before |
Example 13-1:
The order for the test of XMLHttpRequest needs to be reversed for IE 7
to work, or the overrideMimeType method removed, and PHP script adjusted
accordingly, as IE7 does support XMLHttpRequest, but not overrideMimeType.
|
Anonymous |
|
|
Printed |
Page 311
Last paragraph |
In Example 14-6, I have a copy of Example 13-3
should be
In Example 14-6, I have a copy of Example 13-4
|
Anonymous |
|
|
Printed |
Page 314
First paragraph after code |
The text says: "I've highlighted the lines of code where I've made changes based on adding in the logging
functionality."
But lines with changes are not highlighted.
|
Anonymous |
|
|
Printed |
Page 317
Add to end of answer for question 1 |
The variable ".someVariable" is also incorrect.
|
Anonymous |
|
|
Printed |
Page 317
Question 2 |
The dashes should be underscores for CURRENT-MONTH
|
Anonymous |
|
|
Printed |
Page 317
Question 4 |
var octNumber = parseInt(intNumber, 2);
should be
var octNumber = parseInt(intNumber, 8);
|
Anonymous |
|
|
Printed |
Page 318
change solution for Chapter 3 question 2 to |
switch(val) {
case 'one' :
case 'two' :
result = 'OK';
break;
case 'three' :
result = 'OK2';
break;
default :
result = 'NONE';
}
|
Anonymous |
|
|
Printed |
Page 319
|
Change first line of solution to:
var regexp = /fun/g;
|
Anonymous |
|
|
Printed |
Page 323
In answer 5 at the top of the page, the code should be |
var newWindow = window.open("http://help.html", "", "width=200,height=200,toolbar=no,status=no");
|
Anonymous |
|
|