A B C D E F G H I J K L M N O P Q-R S T U V W X Y-Z
&= (assignment) operator, 404
*= (assignment) operator, 404
^= (assignment) operator, 405
/= (assignment) operator, 404
-= (assignment) operator, 27, 404
%= (assignment) operator, 404
+= (assignment) operator, 27, 403-404
|= (assignment) operator, 405
<<= (assignment) operator, 405
>>= (assignment) operator, 405
>>>= (assignment) operator, 405
\ (backslash), 70
& (bitwise AND) operator, 404
| (bitwise OR) operator, 404
^ (bitwise XOR) operator, 404
~ (bitwise NOT) operator, 404
, (comma) operator, 406
/*...*/ comment syntax, 24
// comment syntax, 24
+ (concatenation) operator, 27-28, 403
?: (conditional) operator, 406
- - (decrement) operator, 26
/ (division) operator, 26, 403
== (equality) operator, 405
$() function (prototype.js), 309
$() operator (jQuery), 319
> (greater than) operator, 87, 405
>= (greater than or equal to) operator, 87, 405
++ (increment) operator, 26
<< (left shift) operator, 404
< (less than) operator, 87, 405
<= (less than or equal to) operator, 87, 405
&& (logical AND) operator, 89, 403
|| (logical OR) operator, 89, 403
! (logical NOT) operator, 74, 403
* (multiplication) operator, 26, 403
<!——> notation, 23
!= (not equal) operator, 86, 405
>> (right shift) operator, 404
=== (strict equality) operator, 86, 405
!== (strict not equal) operator, 405
- (unary negation) operator, 26
>>> (zero-fill right shift) operator, 404
<a> element, 356
abort() method, 258
abs method, 407
abstraction, 220
accessing
classes with className, 207-209
acos method, 407
ActionScript, JavaScript support in, 384
addEventListen() method, 146
controlling with JavaScript, 359-361
methods, 359
Adobe tools, JavaScript support in, 383
advanced event handler registration
cross-browser implementation, 147-148
Microsoft method, 147
Ajax
Ajax library
callback function, 276
goals, 274
HTTP GET and POST requests, 275-276
including in HTML page, 278-280
myAjaxLib.js source code, 277-278
overview, 273
returning keyword META information from remote sites, 280-283
XMLHttpRequest instances, 274-275
application structure, 251-253
flow diagram, 255
server responses, 254
XMLHttpRequest object, 253
canceling Ajax calls, 270
debugging
bookmarks, 293
browser caching of GET requests, 297
degradation, 294
escaping content, 297
inappropriate use of Ajax, 295-296
with Internet Explorer, 290-292
links, 293
Permission Denied errors, 297
pop-up information, 295
search engine spiders, 294, 299
security, 296
testing across multiple platforms, 296
implementing with jQuery, 328
ajax() method, 330
get() method, 329
load() method, 329
post() method, 330
sample Ajax form with jQuery, 330-332
server requests
dealing with browser cache, 261-262
server status, monitoring
readyState property, 263
server response status codes, 264
XMLHttpRequest object
creating instances of, 256-258
ajax() method, 330
Ajax.PeriodicalUpdater class, 310-311
Ajax.Request class, 309
alert dialogs, displaying, 49
allowDrop() function, 375
altKey property (events), 143
ampersand (&), 404
anchor elements, 356
AND operators
& (bitwise AND), 404
&& (logical AND), 403
logical AND (&&), 89
animated shooting game example, 242-245
animation
animated shooting game example, 242-245
animating elements with jQuery, 322
animate() method, 324
sliding page elements, 323-324
transitions, 323
CSS3 transitions and transformations, 239-240, 246
setInterval() method, 237, 246
performance optimization, 242
timers, 242
appending child nodes, 187-188
arc() function, 371
arguments
explained, 40
arithmetic operators, 26-27, 403
arrays
array manipulation sample script, 78-79
concatenating, 76
defining with JSON (JavaScript Object Notation), 128
definition of, 74
initializing, 75
length property, 75
methods
slicing, 77
sorting, 77
splicing, 77
<article> element, 366
<aside> element, 366
asin method, 407
assigning values to variables, 25
assumptions, avoiding, 221
atan method, 407
attachEvent function, 147
attr() method, 321
attributes (element)
attributes property (DOM nodes), 180
audio
playing with <audio> element, 369
streaming, 363
<audio> element, 369
autoplay attribute (<video> element), 367
.avi files, 354
avoiding
assumptions, 221
overuse of JavaScript, 217-218
Back button, debugging, 292-293
back() method, 53
backslash (\), 70
behavior layer, 223
best practices
assumptions, avoiding, 221
overuse of JavaScript, avoiding, 217-218
progressive enhancement, 222-223
unobtrusive JavaScript
bitwise operators, 404
bookmarks, debugging, 293
browser extensions
Firefox extensions, 395
Google Chrome extensions
extension to return airport information, 387-388
icon files, 388
JavaScript support in, 383
packing, 393
browser sniffing, 117
browsers
browser history, accessing, 52-53
browser extensions
Firefox extensions, 395
Google Chrome extensions, 384-392
JavaScript support in, 383
packing, 393
browser sniffing, 117
feature detection, 116-118, 226-227
Firefox
extensions, 395
Firebug, 100, 287-290, 299, 401
JavaScript support in, 384
Internet Explorer, 9
F12 Developer Tools, 100
JSON (JavaScript Object Notation) support, 123, 133
buttonReport() function, 41-42
callback functions, 264-265, 276
calling functions, 38
CamelCase naming convention, 25, 220
canceling Ajax calls, 270
canPlayType() method, 368
capturing mouse events
onMouseOut event handler, 31-33
onMouseOver event handler, 31-33
caret (^), 404
Cascading Style Sheets. See CSS styles
CDNs (Content Delivery Networks), 318
Celsius, converting to Fahrenheit, 28-29
changing
classes with className, 207-209
mouse cursor, 215
character strings, assigning to variable values, 25
checkform() function, 140
child nodes (DOM)
inserting, 188
removing, 191
childNodes property (DOM nodes), 174-175
Chome extensions
extension to return airport information, 387-388
icon files, 388
JavaScript support in, 383
packing, 393
popup.html file
classes
accessing using className, 207-209
Ajax.PeriodicalUpdater, 310-311
Ajax.Request, 309
clearRect() method, 371
client-side programming, 8
clientX property (events), 143
clientY property (events), 143
clock application (Ajax), 267-269
cltrlKey property (events), 143
collections, NodeList, 174
comma (,) operator, 406
command chaining (jQuery), 324
comments
HTML comments, 23
JavaScript comments, 24
performance considerations, 24
comparison operators, 86-87, 405
compiled languages, 10
concatenating
arrays, 76
conditional (?:) operator, 406
conditional statements
testing multiple conditions, 88
confirm() method, 50
confirmation dialogs, displaying, 50
constants, mathematical, 61
constructor functions, 108-110
Content Delivery Networks (CDNs), 318
continue statement, 101
control structures. See loops
controls attribute (<video> element), 367
converting
code into unobtrusive code, 228-231
strings
to numbers, 69
to uppercase/lowercase, 73
cookie property (document object), 156
cookieName value, 157
cookies
cookieName value, 157
cookieValue value, 157
expires attribute, 158
path attribute, 158
secure attribute, 158
deleting, 162
document.cookie property, 156
escaping and unescaping data, 156-157
limitations of, 156
security, 166
setting multiple values in, 165-166
testing
cookieValue value, 157
cos method, 407
createCookie() function, 159-162
createElement() method, 185-186
createElementTextNode() method, 186
Crockford, Douglas, 401
cross-browser event handlers, 142-144, 147-148, 152
CSS (Cascading Style Sheets) styles, 201
changing classes using className, 207-209
CSS3 animations
style declarations
placing, 204
style properties, setting, 205-206
stylesheets
DOM styleSheets object, 209
cursor, changing, 215
customized widgets, 349
cycling images on page, 97-100
data types
arrays
associative arrays, 80
associative arrays, simulating, 127
definition of, 74
initializing, 75
length property, 75
definition of, 67
JSON (JavaScript Object Notation) data types, 126
numbers
converting strings to, 69
floating-point numbers, 68
hexadecimal numbers, 68
NaN (not a number), 69
natural numbers, 67
whole numbers, 67
strings
converting to numbers, 69
definition of, 70
maximum length of, 80
Date object
creating with a given date and time, 58
creating with current date and time, 57
setting/editing dates and times, 58-59
time zones, 65
datetime.js, 230
debugging, 94-96. See also error handling, 227-228
Ajax, 287
bookmarks, 293
browser caching of GET requests, 297
degradation, 294
escaping content, 297
inappropriate use of Ajax, 295-296
with Internet Explorer, 290-292
links, 293
Permission Denied errors, 297
pop-up information, 295
search engine spiders, 294, 299
security, 296
testing across multiple platforms, 296
debugging tools
Firebug, 401
JSLint, 401
declaring
CSS styles
placement of style declarations, 204
decrement (- -) operator, 26
default actions (event handlers)
explained, 138
degradation, graceful, 221-222, 294
delete operator, 406
deleteCookie() function, 162-163
deleting cookies, 162
deprecated status, 11
deserialization (JSON)
with eval() function, 123
with native browser support, 123, 133
with parse() function, 123
detachEvent function, 147
detecting browser features, 226-227
development
of JavaScript, 9
of jQuery, 333
dialogs, displaying
alert dialogs, 49
confirmation dialogs, 50
direct instances, declaring, 104-105
disabling stylesheets, 209-211
displayData() function, 391
displaying
alert dialogs, 49
confirmation dialogs, 50
division (/) operator, 26
do ... while loop, 91
document object, 12
cookie property, 156
getElementById() method, 51-52
reading properties of, 16
Document Object Model. See DOM
$(document).ready handler, 318-319
documentation (JSON), 133
documents (HTML), including JavaScript in, 21-23
Dojo library, 305
DOM (Document Object Model), 10
animating DOM elements, 240-241
browser support for, 12
development of, 10
DOM Core, 199
element attributes, editing, 191-192
explained, 11
JavaScript files, loading dynamically, 192-193
levels, 11
nodes
attributes property, 180
determining whether nodes have child nodes, 182
firstChild property, 175
lastChild property, 176
names, 177
nextSibling property, 176
node lists, 174
nodeName property, 177
parentNode property, 176
previousSibling property, 176
objects. See objects
DOM Core, 199
domain attribute (cookies), 157-158
dot notation, 13
downloading
DOM Inspector, 180
drag and drop
drag() function, 375
Dragonfly, 100
drawing with canvas element, 370-372
drop() function, 375
dynamic menu creation, 193-197
E constant, 61
E property (Math object), 407
ECMA (European Computer Manufacturers Association), 9
ECMAScript, 9
editing
editors
Geany, 400
jEdit, 400
Notepad++, 399
SciTE, 400
element nodes, 173
elements
<a>, 356
animate() method, 324
setInterval() method, 237, 246
sliding page elements, 323-324
transitions, 323
<article>, 366
<aside>, 366
<audio>, 369
<embed>, 357
<figcaption>, 366
<figure>, 366
<footer>, 366
getting and setting content of, 320-321
<header>, 366
<nav>, 366
<noscript>, 232
<object>, 357
reading attributes of, 179-180
<section>, 366
with getElementsByTagName(), 177-179
<summary>, 366
<embed> element, 357
ended attribute (<video> element), 367
enhancement, progressive, 222-223
equality (==) operator, 405
error handling, 227-228. See also debugging, 94-96
escaping data, 41, 70-71, 156-157, 297
European Computer Manufacturers Association (ECMA), 9
eval() function, 123
advanced event handler registration
cross-browser implementation, 147-148
Microsoft method, 147
common event handlers, 136
cross-browser event handlers, 142-144, 147-148, 152
inline event handlers, 136
jQuery, 328
onClick, 30-31, 144-145, 148-151
event object
explained, 141
Microsoft approach, 142
W3C approach, 142
events
advanced event handler registration, 146-148
common event handlers, 136
cross-browser event handlers, 142-144, 147-148, 152
inline event handlers, 136
jQuery, 328
onClick, 30-31, 144-145, 148-151
event object
explained, 141
Microsoft approach, 142
W3C approach, 142
mouse events, capturing, 30
properties, 143
exclamation point (!), 403
exp method, 407
expires attribute (cookies), 158
exponential notation, 68
Extensible Markup Language (XML)
compared to JSON, 122
parsing, 285
extensions (browser). See browser extensions
$F() function, 307
F12 Developer Tools, 100
fadeIn() method, 323
fadeOut() method, 323
fadeTo() method, 323
fading
page elements, 323
between transparency and opacity, 238-239
Fahrenheit, converting Celsius to, 28-29
“falsy” values, 74
feature detection, 57, 116-118, 226-227
feedback for users, debugging, 293-294
figcaption element, 366
<figure> element, 366
File interface, 377
FileList interface, 377
files. See also specific files
local files, interacting with, 377-379
finding maximum and minimum, 60
Firebug, 100, 287-290, 299, 401
Firefox
extensions, 395
Firebug, 100, 287-290, 299, 401
JavaScript support in, 384
firstChild property (DOM nodes), 175
controlling with JavaScript, 359-361
methods, 359
flashLoaded() function, 359-361
Flickr, support for JSON, 122
floating-point numbers, 68
floor method, 407
.flv files, 355
footer element, 366
for...in loop, 93
Form object, 308
forms
Form object, 308
sample Ajax form with jQuery, 330-332
forward slash (/), 26
forward() method, 53
fps (frames per second), 236
frames per second (fps), 236
functions. See also methods
Ajax callback functions, 264-265
allowDrop(), 375
animate(), 371
arc(), 371
attachEvent(), 147
callback functions, 276
calling, 38
checkform(), 140
compared to methods, 38
constructor functions, 108-110
detachEvent, 147
displayData(), 391
drag(), 375
drop(), 375
eval(), 123
$F(), 307
getElementArea(), 221
isFinite(), 70
jsonParse(), 125
lineTo(), 370
moveTo(), 370
nesting, 47
outputting user messages with, 41-42
parse(), 123
parseFloat(), 69
parseInt(), 69
returning values from, 43
setInterval(), 97
showVars(), 45
toggleClass(), 208
Try.these, 308
games, animated shooting game, 242-245
Geany, 400
generating random numbers, 60-61
GET requests, 270, 275-276, 297
get() method, 329
getAllResponseHeaders() method, 258
getAttribute() method, 180, 191
getDate() method, 408
getDay() method, 408
getElementArea() function, 221
getElementById() method, 51-52, 117
getElements() method, 308
getElementsByTagName() method, 177-179
getHours() method, 408
getMilliseconds() method, 408
getMinutes() method, 408
getMonth() method, 408
getResponseHeader() method, 258
getSeconds() method, 408
getTime() method, 408
getTimezoneOffset() method, 65, 408
getUTCDate() method, 408
getUTCDay() method, 408
getUTCFullYear() method, 408
getUTCHours() method, 408
getUTCMilliseconds() method, 408
getUTCMinutes() method, 408
getUTCMonth() method, 408
getUTCSeconds() method, 408
getYear() method, 65
global objects, 14
Google Ajax API CDN, 318
Google Apps Script, JavaScript support in, 384
Google Chrome extensions. See Chrome extensions, 383
GotoFrame() method, 359
graphics. See images
greater than (>) operator, 87, 405
greater than or equal to (>=) operator, 87, 405
handling
events. See event handlers
hasChildNodes() method, 182
<header> element, 366
hexadecimal numbers, 68
hide() method, 322
history of jQuery, 333
history (browser), accessing, 52-53
history of JavaScript, 9
HTML (HyperText Markup Language)
comment syntax, 23
elements. See elements
explained, 7
HTML5
<audio> element, 369
learning, 380
web site examples, 380
metatags, 280
HTML5
<audio> element, 369
learning, 380
website examples, 380
HTTP
HyperText Markup Language. See HTML
hyphen (-), 26
icon files for Google Chrome extensions, 388
IDs, selecting elements by, 51-52
testing multiple conditions, 88
image rollovers, creating, 32-33
images
animation
animated shooting game example, 242-245
CSS3 transitions and transformations, 239-240, 246
performance optimization, 242
timers, 242
drawing with canvas element, 370-372
in operator, 406
inappropriate use of Ajax, 295-296
including
jQuery from CDNs (Content Delivery Networks), 318
jQuery UI in web pages, 336-337
increment (++) operator, 26
indexOf() method, 71-72, 75-76, 406
initializing arrays, 75
inline event handlers, 136
insertBefore() method, 188
inserting child nodes, 188
instanceof operator, 406
instantiating objects, 108-110, 256-258
interacting with user
alert dialogs, 49
confirmation dialogs, 50
Internet Explorer, 9
F12 Developer Tools, 100
interpreted languages, 10
isFinite() function, 70
IsPlaying() method, 359
Java, 8
JavaScript Object Notation. See JSON
jEdit, 400
jQuery, 306
command chaining, 324
compatibility with other libraries, 333
development of, 333
$(document).ready handler, 318-319
event handling, 328
implementing Ajax with, 328
ajax() method, 330
get() method, 329
load() method, 329
post() method, 330
sample Ajax form with jQuery, 330-332
including from CDNs (Content Delivery Networks), 318
jQuery CDN, 318
jQuery UI
customized widgets, 349
including in web pages, 336-337
resizing handles, 341
methods
ajax(), 330
attr(), 321
get(), 329
hide(), 322
html(), 320
load(), 329
post(), 330
toggle(), 322
page elements
getting and setting content of, 320-321
jQuery CDN, 318
.js file extension, 22
jScript, 9
JSLint, 401
JSON (JavaScript Object Notation), 121
with eval() function, 123
with native browser support, 123
with parse() function, 123
associative arrays, simulating, 127
compared to XML, 122
data types, 126
documentation, 133
explained, 121
Flickr support for, 122
objects, creating, 127
methods, 128
objects within objects, 129
properties, 128
security, 131
web page, 121
jsonParse() function, 125
junctions, 90
keyCode property (events), 143
keyword META information, returning from remote sites, 280-283
keywords. See functions; methods; statements
language attribute (<script> element), 10
lastChild property (DOM nodes), 176
lastIndexOf() method, 71-72, 75-77, 406
layers
behavior layer, 223
presentation layer, 223
semantic layer, 223
leaving loops
with continue, 101
left shift (>>) operator, 404
length property
arrays, 75
history object, 52
less than (<) operator, 87, 405
less than or equal to (<=) operator, 87, 405
libraries, 303
Ajax library
callback function, 276
goals, 274
HTTP GET and POST requests, 275-276
including in HTML page, 278-280
myAjaxLib.js source code, 277-278
overview, 273
returning keyword META information from remote sites, 280-283
XMLHttpRequest instances, 274-275
Dojo, 305
including in web pages, 314
jQuery. See jQuery
MooTools, 305
Prototype Framework, 305
prototype.js
Ajax.PeriodicalUpdater class, 310-311
Ajax.Request class, 309
$F() function, 307
Form object, 308
Try.these() function, 308
Yahoo! UI Library, 305
LibreOffice.org, JavaScript support in, 383
lineTo() function, 370
links, debugging, 293
load() method, 329
loading
JavaScript files dynamically, 192-193
multimedia
with <a> element, 356
with <embed> element, 357
with <object> element, 357
local files, interacting with, 377-379
local storage with HTML5, 376-377
localStorage object, 376
location object
navigating with, 54
properties, 53
reloading pages, 54
log method, 407
logical AND (&&) operator, 89
logical OR (||) operator, 89
loop attribute (<video> element), 367
loops, 90. See also statements
choosing, 101
do ... while, 91
for...in, 93
leaving with continue, 101
loosely typed languages, 67
lowercase, converting strings to, 73
Math object, 59
constants, 407
finding maximum and minimum, 60
generating random numbers, 60-61
mathematical constants, 61
rounding, 60
mathematical constants, 61
maximum numbers, finding, 60
menus, creating dynamically, 193-197
messages, outputting with functions, 41-42
META information, returning from remote sites, 280-283
metatags, 280
metatags.html, 282
methods, 12. See also functions
abort(), 258
addEventListener, 146
adding with prototype, 111-112
ajax(), 330
alert(), 49
animate(), 324
attr(), 321
back(), 53
canPlayType(), 368
clearRect(), 371
compared to functions, 38
confirm(), 50
createElementTextNode(), 186
defining with JSON (JavaScript Object Notation), 128
fadeIn(), 323
fadeOut(), 323
fadeTo(), 323
flashLoaded(), 359
forward(), 53
get(), 329
getAllResponseHeaders(), 258
getElements(), 308
getElementsByTagName(), 177-179
getFullYear(), 65
getResponseHeader(), 258
getTimezoneOffset(), 65
getYear(), 65
GotoFrame(), 359
hasChildNodes(), 182
hide(), 322
insertBefore(), 188
IsPlaying(), 359
load(), 329
open(), 259
pause(), 368
PercentLoaded(), 359
post(), 330
reload, 54
reload(), 54
removeEventListener, 146
resizable(), 341
Rewind(), 359
serialize(), 308
setAttribute(), 191
setFullYear(), 65
setRequestHeader(), 258
setYear(), 65
slideDown(), 323
slideUp(), 323
StopPlay(), 359
stringify(), 124
tabs(), 347
toDateString(), 59
toggle(), 322
TotalFrames(), 359
toTimeString(), 59
Zoom(), 359
Microsoft CDN, 318
minimum numbers, finding, 60
monitoring server status, 263
readyState property, 263
server response status codes, 264
MooTools library, 305
mouse cursor, changing, 215
mouse events, capturing
onMouseOut event handler, 31-33
onMouseOver event handler, 31-33
.mov files, 354
moveItRight() function, 240-241
moveTo() function, 370
movies. See video
moving ball animation, 370-372
Mozilla Firefox
extensions, 395
Firebug, 100, 287-290, 299, 401
JavaScript support in, 384
.mp3 files, 354
.mp4 files, 355
.mpeg files, 354
.mpg files, 354
multilevel objects (JSON), 129-131
multiline comments, 24
multimedia
audio
playing with <audio> element, 369
streaming, 363
disadvantages of, 363
controlling with JavaScript, 359-361
methods, 359
loading and playing
with <a> element, 356
with <embed> element, 357
with <object> element, 357
video
playing with <video> element, 366-368
multiple conditions, testing for, 88
multiple platforms, testing across, 296
multiple values, setting in cookies, 165-166
multiplication (*) operator, 26
myAjaxLib
callback function, 276
goals, 274
HTTP GET and POST requests, 275-276
including in HTML page, 278-280
myAjaxLib.js source code, 277-278
overview, 273
returning keyword META information from remote sites, 280-283
XMLHttpRequest instances, 274-275
\n (new line) character, 41
nodes, 177
variables, 25
NaN (not a number), 69
natural numbers, 67
<nav> element, 366
navigating
DOM (Document Object Model). See DOM (Document Object Model), 171
with location object, 54
navigator.html file, 55
negation operator (!), 74
negative infinity, 70
nesting functions, 47
Netscape Navigator 4, 9
new line (\n) character, 41
new operator, 406
nextSibling property (DOM nodes), 176
Node js, 395
NodeList, 174
nodeName property (DOM nodes), 177
nodes (DOM)
child nodes
inserting, 188
removing, 191
creating
createElement() method, 185-186
createElementTextNode() method, 186
determining whether nodes have child nodes, 182
names, 177
node lists, 174
properties
attributes, 180
firstChild, 175
lastChild, 176
nextSibling, 176
nodeName, 177
parentNode, 176
previousSibling, 176
nodeValue property (DOM nodes), 176-177
<noscript> element, 232
not a number (NaN), 69
not equal (!=) operator, 405
NOT operators
! (logical NOT), 403
~ (bitwise NOT), 404
Notepad++, 399
numbers, 67
converting strings to, 69
finding maximum and minimum, 60
floating-point numbers, 68
hexadecimal numbers, 68
NaN (not a number), 69
natural numbers, 67
random numbers, generating, 60-61
rounding, 60
whole numbers, 67
object literals, 74
Object Oriented languages, 104
<object> element, 357
object-oriented programming. See OOP
objects. See also OOP (object-oriented programming)
creating direct instances of, 104-105
creating with constructor functions, 108-110
creating with JSON, 127
methods, 128
objects within objects, 129
properties, 128
Date, 57
creating with a given date and time, 58
creating with current date and time, 57
setting/editing dates and times, 58-59
time zones, 65
document, 12
cookie property, 156
getElementById() method, 51-52
reading properties of, 16
event
explained, 141
Microsoft approach, 142
W3C approach, 142
explained, 12
Form, 308
global objects, 14
JSON (JavaScript Object Notation), 13
associative arrays, simulating, 127
compared to XML, 122
data types, 126
explained, 121
Flickr support for, 122
web page, 121
localStorage, 376
navigating with, 54
properties, 53
reloading pages, 54
Math
constants, 407
finding maximum and minimum, 60
generating random numbers, 60-61
mathematical constants, 61
rounding, 60
portability, 119
sessionStorage, 376
styleSheets, 209
confirm() method, 50
XMLHttpRequest
creating instances of, 256-258
obtrusive code, converting into unobtrusive code, 228-231
onBlur event handler, 136
onChange event handler, 136
onClick event handler, 30-31, 136
listing onClick event properties, 144-145
properties, listing, 144
onDblClick event handler, 136
onFocus event handler, 136
onKeydown event handler, 136
onKeypress event handler, 136
onKeyup event handler, 136
onLoad event handler, 136
onMousedown event handler, 136
onMousemove event handler, 136
onMouseOut event handler, 31-33, 136
onMouseOver event handler, 31-33, 136
onMouseup event handler, 136
onreadystatechange property (XMLHttpRequest object), 258
onReset event handler, 136
onSelect event handler, 136
onSubmit event handler, 136, 139-140
onUnload event handler, 136
OOP (object-oriented programming)
advantages of, 104
object creation
constructor functions, 108-110
when to use, 119
opacity, fading between transparency and opacity, 238-239
open() method, 259
opening DOM Inspector, 180
OpenOffice.org, JavaScript support in, 383
Opera Dragonfly, 100
operators
arithmetic operators, 26-27, 403
bitwise operators, 404
comparison operators, 86-87, 405
negation (!) operator, 74
precedence, 27
special operators, 406
string operators, 403
optimizing performance. See performance considerations, 18, 24, 242
OR operators
| (bitwise OR), 404
overuse of JavaScript, avoiding, 217-218
packing extensions, 393
page elements. See elements
page head, adding functions to, 38-39
parentNode property (DOM nodes), 176
parseFloat() function, 69
parseInt() function, 69
parsing
text, 285
XML, 285
path attribute (cookies), 158
pause() method, 368
paused attribute (<video> element), 367
PDF files, JavaScript support in, 383
percent sign (%), 26
PercentLoaded() method, 359
performance considerations
animation, 242
comments, 24
JavaScript, 18
Permission Denied errors, 297
PHP-enabled web servers, 282
placing style declarations, 204
playing multimedia
with <audio> element, 369
with <a> element, 356
with <embed> element, 357
with <object> element, 357
plus sign (+), 403
pop-up information, 295
popup.html Google Chrome extension
basic popup.html file, 389-391
complete popup.html file, 391-392
icon files, 388
returning airport information, 387-388
post() method, 330
poster attribute (<video> element), 367
pow method, 407
precedence of operators, 27
presentation layer, 223
preventing default actions, 138-141
previousSibling property (DOM nodes), 176
procedural programming, 103
programs, 21
Ajax clock application, 267-269
definition of, 8
progressive enhancement, 222-223
properties. See also specific properties
defining with JSON (JavaScript Object Notation), 128
explained, 12
reading, 16
stringlike properties, 156
protocols, stateless, 155
Prototype Framework library, 305
prototype keyword, extending objects with, 111-115
prototype.js library
Ajax.PeriodicalUpdater class, 310-311
Ajax.Request class, 309
$F() function, 307
Form object, 308
Try.these function, 308
QuickTime files, 354
.ram files, 354
random method, 408
random numbers, generating, 60-61
reading
document object properties, 16
readystate property (XMLHttpRequest object), 258, 263-264
Real Audio files, 354
RealVideo files, 354
reload() method, 54
reloading web pages, 54
remote sites, returning keyword META information from, 280-283
removeEventListen method, 146
removing
child nodes, 191
rendering context, 370
replacing
substrings within strings, 72
requests
Ajax server requests
dealing with browser cache, 261-262
HTTP GET and POST requests, 270, 275-276, 297
XMLHttpRequest
creating instances of, 256-258
overview, 256
Resig, John, 333
resizable() method, 341
resizing handles, adding, 341
responding to events. See event handlers
responseAjax() function, 264-265
responses (server), 254
responseText property (XMLHttpRequest object), 258, 265-266, 285
responseXML property (XMLHttpRequest object), 258, 265-267
return values, 43
Rewind() method, 359
right shift (<<) operator, 404
.rm files, 354
rounding numbers, 60
SciTE, 400
screenX property (events), 143
screenY property (events), 143
<script> element, 10-11, 21-22
scripts. See programs
search engine spiders, 294, 299
<section> element, 366
secure attribute (cookies), 158
security
Ajax, 296
cookies, 166
JSON, 131
selecting
with getElementsByTagName(), 177-179
semantic layer, 223
sending Ajax server requests, 260-261
serialization with JSON (JavaScript Object Notation), 124-126
serialize() method, 308
server requests (Ajax)
dealing with browser cache, 261-262
server responses, 254
server status, monitoring, 263
readyState property, 263
server response status codes, 264
server-side programming, 8
sessionStorage object, 376
setAttribute() method, 191
setDate() method, 408
setHours() method, 409
setInterval() method, 97, 237, 246, 371
setMilliseconds() method, 409
setMinutes() method, 409
setMonth() method, 409
setRequestHeader() method, 258
setSeconds() method, 409
setTime() method, 409
setting
setUTCDate() method, 409
setUTCFullYear() method, 409
setUTCHours() method, 409
setUTCMilliseconds() method, 409
setUTCMinutes() method, 409
setUTCMonth() method, 409
setUTCSeconds() method, 409
setYear() method, 65
shiftKey property (events), 143
ShockWave Flash. See Flash, 358-361
shooting game (animated), 242-245
showVars() function, 45
simulating associative arrays, 127
sin method, 407
slash (/), 403
slicing arrays, 77
slideDown() method, 323
slideUp() method, 323
sliding page elements, 323-324
sorting
arrays, 77
sound
playing with audio element, 369
streaming, 363
special operators, 406
Sphere, JavaScript support in, 384
splicing arrays, 77
split method, 406
splitting strings, 73
sqrt method, 407
stateless protocols, 155
statements. See also loops
comments, 24
continue, 101
do ... while, 91
explained, 23
for...in, 93
testing multiple conditions, 88
function, 38
null, 74
static web pages, 7
status of server, monitoring
readyState property, 263
server response status codes, 264
status property (XMLHttpRequest object), 258
statusText property (XMLHttpRequest object), 258
stock price reader program, 311-312
StopPlay() method, 359
storage, local storage with HTML5, 376-377
streaming audio/video, 363
strict equality (===) operator, 405
strict not-equal-to (!==) operator, 405
stringify() method, 124
stringlike properties, 156
strings
assigning to variable values, 25
converting
to numbers, 69
to uppercase/lowercase, 73
definition of, 70
extending, 114
JSON strings
creating, 124
maximum length of, 80
operators, 403
replacing substrings in, 72
splitting, 73
styles (CSS)
style declarations
placing, 204
style properties, setting, 205-206
stylesheets
DOM styleSheets object, 209
stylesheets
DOM styleSheets object, 209
substring method, 406
subtraction (-) operator, 26
<summary> element, 366
supporting users with JavaScript disabled, 232
switching stylesheets, 209-211
tabs() method, 347
tags. See elements
tan method, 407
telltime() function, 63, 228-230
temperature.html, 29
testing
Ajax across multiple platforms, 296
cookies
in multiple browsers, 18
multiple conditions, 88
text nodes, 173
text parsing, 285
time
time zones, 65
timers, 242
title, selecting stylesheets by, 213-214
toDateString() method, 59, 409
toggle() method, 322
toggleClass() function, 208
toggling between stylesheets, 210-211
toLocaleDateString() method, 409
toLocaleString() method, 409
toLocaleTimeString() method, 409
toLowerCase method, 406
tools
Firebug, 401
jEdit, 400
JSLint, 401
Geany, 400
Notepad++, 399
SciTE, 400
WDG (Web Design Group) validation service, 401
TotalFrames() method, 359
toTimeString() method, 59, 409
toUpperCase() method, 72-73, 406
toUTCString() method, 409
transformations, animating, 239-240, 246
transitions, animating, 239-240, 246, 323
transparency, animating, 238-239
Try.these function, 308
turning off JavaScript, 232
type attribute
events, 143
<script> element, 10
typeof operator, 117-118, 226, 406
undefined values, 74
Universal Time (UTC), 65
unobtrusive JavaScript
uppercase, converting strings to, 73
user interaction
alert dialogs, 49
confirmation dialogs, 50
user messages, outputting with functions, 41-42
users with JavaScript disabled, supporting, 232
UTC (Universal Time), 65
UTC() method, 410
valueOf() method, 410
values
assigning to variables, 25
cookie values
cookieName, 157
cookieValue, 157
returning from functions, 43
undefined values, 74
variables
assigning values to, 25
naming, 25
undefined, 74
VBScript, 9
video
loading and playing
with <a> element, 356
with <embed> element, 357
with <object> element, 357
streaming, 363
void operator, 406
volume attribute (<video> element), 367
W3C (World Wide Web Consortium), 10, 401
.wav files, 354
WDG (Web Design Group) validation service, 401
web browsers. See browsers
web pages
including Ajax library in, 278-280
including JavaScript in, 21-23
including jQuery UI in, 336-337
including libraries in, 314
menus, creating on-the-fly, 193-197
navigating with location object, 54
reloading, 54
static pages, 7
web servers, PHP-enabled, 282
WebM, 367
whole numbers, 67
widgets
customized widgets, 349
confirm() method, 50
.wma files, 354
.wmv files, 354
World Wide Web Consortium (W3C), 10, 401
writing
Google Chrome extensions, 384-386
XAMPP, 282
XHTML, 31
XML (Extensible Markup Language)
compared to JSON, 122
parsing, 285
XMLHttpRequest object
creating instances of, 256-258, 274-275
open(), 259
XOR operators (^), 404
Yahoo! UI Library, 305
zero fill right shift (>>>) operator, 404
Zoom() method, 359