Index

Symbols

! (not), 16

> (greater than), 16

< (less than), 16

% (modulus), 15

" (quotes), 432

# (hash symbol), 19

$ (dollar sign), 176, 365–366, 379

&nbsp; (non-breaking space), 51

& (and) operator, 70

&& (and) operator, 16, 74

() (parentheses)

in functions, 25, 28

in loops, 51

in methods, 12

in regular expressions, 174

* (asterisk), 15, 175

+ (plus sign) operator, 15, 174

++ (increment) operator, 15, 53

- (minus sign) operator, 15

-- (decrement) operator, 15

. (dot/period), 12

/ (slash), 15, 122, 173

// (comment indicator), 30

/* and */ (comment indicators), 29

; (semicolon), 24, 173, 425, 435

= (equals sign), 15, 16, 34

== (equivalence), 16, 34

? (question mark), 34, 175

@ character, 175

[] (brackets), 174

(backslash), 122, 174

^ (caret), 174

{} (braces), 25, 34

| (or) operator, 70

|| (or) operator, 16, 74

3-state rollovers, 91–92, 192

12-hour time format, 272

24-hour time format, 272

A

accented characters, 441–443

accessibility, 296

accordion menus, 382–385

action attribute, 134

ActiveX, 332, 338

Adaptive Path, 327

Adobe

Dreamweaver. See Dreamweaver

Flash, 4, 104

Photoshop, 306, 444

Ajax, 325–362

article about, 327

auto-completing form fields with, 357–362

and back buttons, 330

browser considerations, 329

and caching, 338, 348

coining of term, 9, 327

drawbacks/problems, 329–330, 338, 348

engine, 328

how it works, 328–329

and jQuery, 398–399

and JSON format, 260, 349

parsing server data with, 339–345, 349–352

popularity of, 327

previewing links with, 353–356

purpose of, 8

recommended video on, 493

refreshing server data with, 346–348

requesting/reading server data with, 331–338, 349–352

and server-side technologies, 330

testing, 338

ways of using, 325–326

Web technologies included in, 9, 327, 362

Ajax Essential Training, 493

Ajaxian blog, 492

alert boxes, 218

alert() method, 32

alert windows, 31–32

alphabetizing names, 187–188

alt attribute, 82

America Online (AOL), 456, 442

AM/PM, adding to time, 271, 273

anchor tags (<a>), 22, 87

and (&) operator, 70

and (&&) operator, 16, 74

animated GIFs, 104, 105

animation, 81, 83, 85, 104–105

annotating scripts, 29–30

anonymous functions, 89, 90, 136

AOL (America Online), 42, 84, 456

Apache, 172

appendChild() method, 244, 253

Apple Safari. See Safari

applets, Java, 4, 5

arithmetic operators, 15

arrays

declaring, 59

defined, 59

updating, 62–63

using string, 77–80

assignment operators, 16

asterisk (*), 15, 175

Asynchronous JavaScript and XML, 9, 327. See also Ajax

<a> (anchor) tags, 22, 87

Atom feeds, 340

attributes

action, 134

alt, 82

autocomplete, 358

class, 18–19, 70, 72, 74, 99, 134

deprecated, 24

for, 134

height, 82

href, 22

id. See id attribute

language, 24

maxlength, 134

name, 116, 134

selected, 134

size, 134

src, 22, 26, 82, 116

style, 70

target, 118–119

type, 24, 134

value, 134

width, 82

audio player plugin, 420–424

autocomplete attribute, 358

B

back button, 117, 330

background color, changing Web page, 432, 433–435

background properties (CSS), 483

backslash (), 122, 174

Bare Bones Software, 20

BBEdit, 20, 172

binary math, 74

binary values, 70, 71

Bingo cards

adding interactivity to, 68–70

applying styles to, 52, 68–70

avoiding duplicate numbers in, 62–63, 64

checking for winning state, 71–74

creating skeleton for, 50–51

limiting range of values in, 59

possible winning patterns for, 75

range of allowable numbers for, 53, 59

using loop to create table for, 53–54

bit.ly, 449

bits, 70, 71, 75–76

bitwise arithmetic, 70, 72, 75–76

blind users, 296

block-level elements, 18

blogs. See weblogs

blur() method, 132

body scripts, 23

<body> tags, 22, 23

bookmarklets, 425–452

for changing page’s styles, 433–435

for converting kilometers to miles, 446

for converting RGB values to hex, 444–445

creating

in Firefox, 426

in Internet Explorer, 428–431

in Safari, 427

defined, 425

for displaying ISO Latin characters, 441–443

for doing complex calculations, 447–448

and IE security, 431

for looking up words, 436–438

for mailing Web pages, 451

origin of, 427

repositioning, 427

for resetting page background, 432

for resizing pages, 452

for shortening URLs, 449

use of semicolons in, 425, 435

use of single vs. double quotes in, 432

for validating pages, 450

for viewing images, 439–440

vs. other JavaScript code, 425

bookmarklets.com, 427

books

Dreamweaver: Visual QuickStart Guide, 138

HTML, XHTML, and CSS: Visual QuickStart Guide, 2

JavaScript, The Definitive Guide, 493

Perl and CGI for the World Wide Web: Visual QuickStart Guide, 176

ppk on JavaScript, 493

Pro JavaScript Techniques, 493

Styling Web Pages with CSS: Visual QuickProject Guide, 481

Boolean values, 15, 61, 63, 70, 77

box properties (CSS), 485

braces ({}), 25, 34

brackets ([]), 174

browser compatibility, 398

browser detection, 58

browser objects, 11. See also objects

browsers. See also specific browsers

and Ajax, 329, 348

and alert boxes, 32

and browser detection, 58

and caching, 348

and case-sensitivity, 480

and cookies, 219–220

and Daylight Savings Time, 271

and DOM, 242, 438

and ECMAScript, 458

and event handlers, 69

and external JavaScript files, 28

and JavaScript toolkits, 373

and JavaScript versions, 454

performing word lookups in, 436–438

and pop-up windows, 129

and resizing of images, 90

and rollovers, 84, 90

and security problems, 431

testing scripts in different, 130

viewing document tree structure in, 13

and Year 2000 Problem, 277

browser security settings, 129

browser windows, 127. See also windows

buttons

back, 117, 330

radio, 156–158

submit, 133, 139, 142, 212

Buzzword Bingo game, 77–80

C

C#, 3

C/C++, 3

cache files

and Ajax, 338, 348

and external scripts, 28

and onload/onunload events, 136, 138

and rollovers, 85

and select-and-go menus, 136

calculators, 447–448

calendars

adding to Web pages, 403–407

Google, 10

calendar widget, 403–407

callback function, 352

calling functions, 25

Camino, 454

capitalizing names, 183–185

caret (^), 174

Cascading Style Sheets, 9. See also CSS

case-sensitivity, 15, 90, 480

case statements, 43–45

Castro, Elizabeth, 2, 176

catch statement, 47

CDN (Content Delivery Network), 367

CGI programs

and forms, 133

for getting from one page to another, 139

and JavaScript, 7

meaning of acronym, 7

recommended book on, 176

characters, displaying ISO Latin, 441–443

charts, 306–314

code for drawing, 308–311

HTML page for generating, 306

script containing styles for, 307

source of statistics for, 314

child frames, 117

Chrome, 28, 58, 242, 373, 431, 458

class attribute, 18–19, 70, 72, 74, 98

classes, CSS pseudo-, 482

client machines, reading/writing files on, 7

client-side languages, 4, 6, 7

closing windows, 7

Cocoa-based programs, 438

code-checking tool, 494

code-writing tool, 495

color

changing Web page background, 432, 433–435

converting RGB to hexadecimal, 444–445

properties (CSS), 483

color-picker script, 369–370

comment indicators (/* and */), 29

commenting scripts, 29–30

Common Gateway Interface, 133. See also CGI

Communicator, Netscape, 454

comparison operators, 16

compile() method, 186

conditionals

if/else, 33–34, 43

multi-level, 43–45, 276

switch/case, 43–45, 276

use of && and || in, 74

confirm() method, 33–34

container tags, 23

Content Delivery Network (CDN), 367

converters

kilometers-to-miles, 446

RGB-to-hexadecimal, 444–445

cookies, 219–240

counting, 219, 228–230

defined, 219

deleting, 231–232

displaying “New to You” message with, 235–240

format for typical, 221

handling multiple, 223, 233–234

how browsers handle, 219

misconceptions about, 219–220

reading, 225

setting, 6, 221–224

showing, 226–227

ways of using, 219

Coordinated Universal Time, 266, 283

Core JavaScript Reference/Guide, 490

countdown script, 274–277

counter programs, 230

counters, 50, 53, 228–230

country pop-up menus, 140

createElement() method, 244

createTextNode() method, 244

CSS

and Ajax, 9, 327

basic concepts, 482

color units, 488

combining JavaScript and, 68–70

and jQuery, 364, 368, 379

length units, 488

meaning of acronym, 9

and object literals, 257

properties, 483–488

pseudo-elements/classes, 482

purpose of, 17

recommended books on, 2, 481

reference, 481–488

styling Bingo card with, 52

tools for creating, 20

and HTML, 17

CSS 2.0 specification, 481

CSS 2.1 specification, 481

.css file extension, 20

customizing messages

for time of day, 265

for weekday vs. weekend, 264

cycling banners

adding links to, 106–107

creating, 104–105

displaying random images in, 113–114

D

data

accessing other people’s, 345

automatic entry of, 357–362

parsing, 339–345, 349–352

presenting tabular, 49, 390–392

refreshing, 346–348

requesting/reading, 331–338, 349–352

using jQuery with external, 411–419

date methods, 283–284

datepicker widget, 403–407

dates. See also calendars

comparing two, 277

displaying by time zone, 266–271

distinguishing between weekdays/weekends, 264

dynamically displaying on Web page, 262–263

how JavaScript stores, 277

Daylight Savings Time, 271

day/month pop-up menus, 140–141

Debugger, Firebug, 494

Debugger, Venkman, 490–491

decimal math, 74

deprecated attributes, 24

detection methods, 58

DHTML, 42, 373

dialogs, 386–387

dictionary-lookup script, 436–438

<div> tags, 18

documentation

JavaScript, 490

jQuery, 376

node manipulation, 260

Document Object Model, 9. See also DOM

document tree structure, 13, 243

document.write() method, 28

Dojo, 373

dollar sign ($), 176, 365–366, 379

DOM

and Ajax, 9, 327

defined, 13

meaning of acronym, 9

and nodes, 13, 241–243

scripting, 42

and W3C, 242, 243

and Web browsers, 242, 438

DOM-2, 242–243

DOM-3, 243

DOM Inspector, 13, 459

dots-follow-cursor script, 209

dot syntax, 12–13, 196

do/while loops, 64–65, 78

draggable dialogs, 387

dragging/dropping page elements, 408–410

Dreamweaver

jump menus, 138

recommended book on, 138

and regular expressions, 172

scripting in, 20

Dreamweaver: Visual QuickStart Guide, 138

drop shadows, 99

Dynamic HTML, 42, 373

dynamic iframes, 123–124

dynamic pages, 261–282

converting 24-hour to 12-hour time, 272–273

creating countdowns, 274–277

customizing message for time of day, 265

customizing message for weekday vs. weekend, 264

defined, 261

and jQuery, 368

moving objects in, 281–282

putting current date on page, 262–263

E

ECMA-262 specification, 454, 457. See also ECMAScript

ECMAScript

bindings, 243

flavors of, 457–458

and JavaScript versions, 454

and Netscape, 457

official specification for, 457

reserved words, 478–479

ejohn.org, 376

element nodes, 13, 243, 244

elements

block-level vs. inline, 18

CSS pseudo-, 482

highlighting page, 378–381

identifying, 19

modifying, 19

else statements, 34, 43

Emacs, 20

email, sending Web pages via, 451

email addresses

validating, 166–170, 173–176

verifying, 169

equals sign (=), 15, 16, 34

error-handling script, 46–47

error messages, 46–47, 201

escaping characters, 174

event handlers, 195–218

defined, 14, 195

for form events, 212–215

onblur, 213–214

onchange, 212

onclick, 213

onfocus, 215

onreset, 212

onselect, 212

onsubmit, 212

importance of, 195

for key events, 216–218

onkeydown, 216–217

onkeypress, 218

onkeyup, 218

list of common, 14

for mouse events, 204–211

onclick, 211

ondblclick, 210

onmousedown, 204–206

onmousemove, 207–209

onmouseout, 210

onmouseover, 210, 353

onmouseup, 206, 211

reference, 465–476

for window events, 196–203

onabort, 201

onblur, 203

onerror, 201

onfocus, 202

onload, 14, 197–199

onmove, 201

onresize, 200–201

onunload, 14, 136, 200

event property, 69

events. See also event handlers

defined, 14

form, 212–215

key, 216–218

mouse, 204–211

window, 196–203

evt property, 69

Excel. See Microsoft Excel

exec() method, 184, 186

external scripts, 26–28

extracting strings, 180–182

eyeballs script, 207–209

F

favelets, 425

favorites, 425

fields

auto-completing, 357–362, 374–375

checking one against another, 147–148

identifying/marking problem, 149–150

making them required, 142–146

setting one with another, 159–161

validating email addresses in, 166–170, 173–176

validating zip codes in, 162–165

file names, validating, 178–179

finally {} block, 47

Firebug Debugger, 494

Firebug Lite, 494

Firefox

and alert boxes, 32

creating bookmarklets in, 426

debugger, 491, 494

and DOM-2, 242

DOM Inspector, 13, 459

and ECMAScript, 458

and external JavaScript files, 28

and focus() method, 214

and JavaScript, 454

and JavaScript toolkits, 373

non-standard window event handlers, 138

and oncontextmenu events, 206

and onkeydown events, 217

and onload events, 136, 138

and onmousedown events, 206

and page caching, 136, 138

performing word lookups in, 436–437

window defaults, 130

and Year 2000 Problem, 277

Flanagan, David, 493

Flash animations, 4, 104

Flickr, 325, 339–345, 349–352

focus() method, 132, 214

following-eyes script, 207–209

font properties (CSS), 483

fonts, serif vs. sans-serif, 315, 318

for attribute, 134

for loops, 50, 53, 54

formatting

properties (CSS), 486

strings, 183–191

list of names, 183–188

phone numbers, 189–191

time, 272–273

form event handlers, 212–215

onblur, 213–214

onchange, 212

onclick, 213

onfocus, 215

onreset, 212

onselect, 212

onsubmit, 212

form-handling scripts

changing menus dynamically, 140–141

checking one field against another, 147–148

creating select-and-go menu, 135–138

identifying problem fields, 149–150

making fields required, 142–146

making sure user picks radio button, 156–158

setting field value automatically, 159–161

validating email addresses, 166–170, 173–176

validating multi-element form, 151–155

validating zip codes, 162–165

forms, 133–193

auto-completing fields in, 357–362, 374–375

checking one field against another in, 147–148

how they work, 133

identifying problem fields in, 149–150

for jumping from one page to another, 139

making fields required in, 142–146

purpose of, 133

setting field values automatically in, 159–161

tags/attributes, 134

using radio buttons in, 156–158

validating email addresses in, 166–170, 173–176

validating file names in, 178–179

validating multi-element, 151–155

validating URLs in, 178–179

validating zip codes in, 162–165

<form> tags, 134, 139

form validation, 133, 212

forums, jQuery, 376

frames, 115–126

HTML tags/attributes, 116

inline, 118. See also iframes

keeping pages out of, 117

reduced popularity of, 115

setting target for, 118–119

sharing functions between, 125–126

framesets, 117, 118. See also frames

frameworks, JavaScript, 363–364, 367, 373, 377

functions. See also specific functions

anonymous, 89, 136

calling, 25

components of, 25

defined, 25

naming, 25, 479

passing values to, 55–56

sharing between documents, 125–126

use of parentheses in, 28

function values, 15

G

Garrett, Jesse James, 9, 327

generated content properties (CSS), 484

getElementById() method, 27, 459

getElementsByTagName() method, 245, 246, 247

getFullYear() method, 277

getHours() method, 265

getTime() method, 277

getYear() method, 277

GIF images, 90, 104, 105

GIFs, spacer, 113

Gmail, 10, 325

GMT, 266, 283

goo.gl, 449

Google

and Ajax, 10

browser. See Chrome

and jQuery, 367

Google Calendar, 10

Google Docs, 10

Google Gmail, 10, 325

Google Instant, 362

Google Maps, 8, 10, 325

Google Maps Mania, 10

googlemapsmania.blogspot.com, 10

graphics. See also images

animating, 81

preparing for rollovers, 90

Greenwich Mean Time, 266, 283

grep, 171

H

<h1>...<h6> tags, 22

hash symbol (#), 19

header scripts, 23

<head> tags, 22, 23

“Hello, Cleveland!” script, 2

“Hello, world!” script, 23, 27, 29–30, 426

hexadecimal, converting RGB values to, 444–445

hide() method, 379, 381

highlighting new elements, 378–381

hijacking pages, 117

hit counters, 230

hover() method, 372–373

href attribute, 22

HTML

and Ajax, 9, 327

attributes, 22, 49, 82, 116, 134

and case, 90

classic style of, 18

and CSS, 17

deprecation of attributes in, 24

evolution of, 1

forms, 133

modern, 17

purpose of, 17

recommended book on, 2

separating JavaScript from, 41, 43

tags, 22, 49, 82, 116, 134

tools for writing, 20

writing JavaScript-friendly, 17–19

and W3C validation, 17

HTML, XHTML, and CSS: Visual QuickStart Guide, 2

.html file extension, 20

HTML Source mode, 20

<html> tags, 22

Hypertext Markup Language. See HTML

I

id attribute

and forms, 134

and frames, 116

and “Hello, world!” script, 27

and images, 82, 103

manipulating cell contents with, 51

purpose of, 18, 19, 22

IE. See Internet Explorer

if/else conditionals, 33–34, 43, 57

iframes

creating content for, 122

creating dynamic, 123–124

defined, 118

loading, with JavaScript, 120

working with, 121–122

images, 81–114

annotating, 96

creating illusion of animation with, 85

in cycling banners, 105

cycling with random start, 113–114

displaying random, 111–112

forcing users to download, 105

HTML tag/attributes for, 82

preparing for rollovers, 90

presenting as slideshows, 108–110

for simple rollovers, 83–84

for three-state rollovers, 91–92, 192

viewing table of, 439–440

<img> tags, 82, 86, 90

increment step, for loop, 54

index number, 59

initialization step, for loop, 54

inline elements, 18

innerHTML property, 27, 28, 42, 245

<input> tags, 134

insertBefore() method, 253

interactive Web applications, 8

interactivity, 1, 6, 68–70, 369–373

internal scripts, 26

Internet Explorer

and alert boxes, 32

and AOL, 456

creating bookmarklets in, 428–431

and DOM-2, 242

and ECMAScript, 458

and event handlers, 69

and external JavaScript files, 28

and getFullYear() method, 277

and JavaScript toolkits, 373

and oncontextmenu events, 206

and onkeydown events, 217

and onmousedown events, 206

performing word lookups in, 436–437

and pop-up windows, 129

and rollovers, 84, 90

scripting capabilities, 5

security problems, 431

and security settings, 129

and tabbed browsing, 129

versions of, 455, 456

viewing document’s tree structure in, 13

window defaults, 130

and XMLHttpRequest object, 332, 338

Year 2000 Problem, 277

Internet time server, 271

iPhone, 80

isNaN() method, 47

ISO Latin characters, 441–443

J

Java

applets, 4, 5

cross-platform compatibility of, 3, 4

developers of, 3

and Microsoft, 3

and regular expressions, 172

vs. JavaScript, 3

vs. other programming languages, 3

ways of using, 4

JavaScript

adding visual interest to Web pages with, 81

and AOL, 42, 456

applying styles with, 68–70

and browser compatibility, 398

calculator, 447–448

case-sensitivity of, 15

as client-side language, 7

combining CSS and, 68–70

and cookies, 219–220. See also cookies

documentation, 490

and DOM, 13, 243

enhancing links with, 39–41

evolution of, 1

frameworks, 363–364, 367, 373, 377

hiding from users, 28, 204–206

how events are handled in, 14

inventor of, 1

libraries. See JavaScript frameworks

limitations of, 7

loading iframes with, 120

Math object, 447

Microsoft version of, 5, 42

modifying document tree structure with, 13

and Netscape, 1, 5, 42, 454

object flowchart, 459–464

object hierarchy, 460

as object-oriented language, 11

object table, 465–476

operators, 15–16

as programming language, 2

purpose of, 1, 17

recommended books on, 493

recommended video on, 493

and regular expressions, 171, 172

reserved words, 477–480

resources, 489–496

rewriting with object literals, 257–260

as scripting language, 2

and standards-compliant HTML, 17

terminology, 42

toolkits. See JavaScript frameworks

tools for writing, 20, 363–364

tutorials, 493

use of semicolons in, 24

using functions in, 25

value types, 15

versions, 453, 454–456

vs. Java, 3

ways of using, 6

JavaScript, The Definitive Guide, 493

JavaScript Center, 490

JavaScript Essential Training, 493

JavaScript Guide, Netscape, 427

JavaScript Object Notation (JSON), 260. See also JSON format

JavaScript World, 2, 489

javascriptworld.com, see JavaScript World

Jobs, Steve, 80

JPEG images, 105

jQuery, 363–424

adding to page, 365–366

adding user interaction with, 369–373

and Ajax, 398–399

alternatives to, 373

auto-completing fields with, 374–375

and browser compatibility, 398

calendar widget, 403–407

and CSS, 364, 368, 379

designing with

creating accordion menus, 382–385

creating custom themes, 400–402

creating smarter dialogs, 386–387

highlighting new elements, 378–381

sorting tables, 393–396

striping tables, 390–392

documentation, 376

and dollar sign (?), 365–366

downloading, 376

as foundation, 398–399

forums, 376

and JSON, 398–399, 411

plugins, 376, 399, 420–424

purpose of, 364

resources, 376

serving, 367

strengths of, 364, 373, 398

themes, 385, 388, 400–402

tutorials, 376

updating buttons with, 372–373

updating page with, 368

use of dollar sign ($) in, 379

user interface (UI). See jQuery UI

using with external data, 411–419

versions, 366, 367

and “yellow fade,” 377, 378

jQuery UI, 376, 377, 378, 381, 396, 400

ThemeRoller. See ThemeRoller

themes, 385, 388, 400–402

JSBin, 495

JScript, 5, 42, 455, 491

JSFiddle, 495

.js file extension, 20, 26, 206

JSHint, 494

JSON format, 9, 260, 349–352, 398–399, 411

jump menus, 138

K

Kangas, Steve, 427

key event handlers, 216–218

onkeydown, 216–217

onkeypress, 218

onkeyup, 218

keywords

this, 41, 260

var, 35, 36

kilometers-to-miles converter, 446

Koch, Peter-Paul, 492, 493

L

<label> tags, 134

language attribute, 24

languages

client-side, 7

object-based, 11

object-oriented, 11

scripting, 2, 5

Latin characters, ISO, 441–443

layers, hiding/displaying, 278–280

leap year, 141

length units (CSS), 488

libraries, JavaScript. See frameworks, JavaScript

light table script, 408–410

limiting step, for loop, 54

link enhancement script, 39–40

links

enhancing with JavaScript, 39–41

previewing, 95, 353–356

redirecting users with, 37–38

triggering rollovers from, 93–98

Linux, 3

list properties (CSS), 487

lists, 292

<li> tags, 292

literal values, 16

LiveScript, 5, 454

loops

counters for, 50, 53

importance of, 50

specific types

do/while, 64–65, 78

for loops, 50, 53, 54

lynda.com, 493

M

Macintosh, 455

Mac OS X

and AOL, 456

Camino, 454

dictionary/thesaurus window, 438

and ECMAScript, 458

and Java, 3

text editors, 20

Macworld Expo, 80

mailing Web pages, 451

mailto links, 451

MapQuest, 8

mashups, 10

match() method, 186

math, binary vs. decimal, 74

Math object

abs() method, 447

acos() method, 447

asin() method, 447

atan() method, 447

ceil() method, 447

cos() method, 447

exp() method, 447

floor() method, 347, 447

log() method, 447

max() method, 447

min() method, 447

pow() method, 447

random() method, 54, 126, 347

round() method, 447

sqrt() method, 447

tan() method, 447

maxlength attribute, 134

menus

accessibility considerations, 296

accordion, 382–385

changing dynamically, 140–141

horizontal vs. vertical, 293

jump, 138

outline-style, 285

pop-up, 140–141

pull-down, 289–296

select-and-go, 135–138

sliding, 286–288

methods

combining with objects/properties, 12–13

defined, 12

distinguishing from properties, 12

reference, 465–476

for RegExp object, 186

for strings, 186

use of parentheses in, 12

Microsoft

and ECMAScript, 457–458

Excel, 306

Internet Explorer. See Internet Explorer

and Java, 3

and JScript, 5, 42, 455

JScript blog, 491

JScript Language site, 491

Windows. See Windows

Word, 20, 172

miles, converting kilometers to, 446

military time, 272

modifiers, regular expression, 177

mouse click codes, 206

mouse event handlers, 204–211

onclick, 211

ondblclick, 210

onmousedown, 204–206

onmousemove, 207–209

onmouseout, 210

onmouseover, 210, 353

onmouseup, 206, 211

mouseout() method, 372–373

Mozilla. See also Firefox

and browser detection, 58

debugger, 491

JavaScript Developer Center, 490

and JavaScript versions, 454

Mozilla Hacks blog, 491

MSIE. See Internet Explorer

multi-level conditionals, 43–45, 276

N

name attribute, 116, 134

names

capitalizing list of, 183–185

generating silly, 301–305

reversing list of, 180–182

sorting list of, 187–188

navigation menus, 135

Navigator

and ECMAScript, 458

and JavaScript, 5, 454

and LiveScript, 5, 454

and Year 2000 Problem, 277

nested if statements, 43

Netscape

and AOL, 456

Communicator, 454

and ECMAScript, 457, 458

and external JavaScript files, 28

and following-eyes script, 209

and JavaScript, 1, 5, 42, 454

JavaScript Guide, 427

and LiveScript, 5

Navigator. See Navigator

and rollovers, 84, 90

“New to You” messages, 235–240

node manipulation, 241, 242–243, 260

nodes, 241–260

adding, 244–245

defined, 13

deleting, 246–250

and DOM, 13, 241–243

inserting, 251–253

replacing, 254–256

types of, 13, 243

vs. innerHTML, 245

non-breaking space, 51

<noscript> tags, 32

Notepad, 20

null values, 15, 35

numbers

random, 54, 347

validating, 190–191

number sign (#), 19

numeric values, 15

O

object-based languages, 11

object detection, 57–58

object flowchart, 459–464

object hierarchy, 460

object literals, 257–260

sample scripts, 258–259, 372–373

similarity to CSS, 257

use of this with, 260

vs. standard procedural JavaScript, 257, 260

object-oriented languages, 11

objects

combining with properties/methods, 12–13

defined, 11

detecting, 57–58

methods of, 12

naming, 11

properties of, 12

reference, 465–476

object table, 465–476

<object> tags, 4

object values, 15

offline resources, 493

onabort events, 14, 201

onblur events, 14, 203, 213–214

onchange events, 14, 212

onclick events, 14, 38, 211, 213

oncontextmenu events, 206

ondblclick events, 210

onerror events, 14, 201

onfocus events, 14, 202, 215

onkeydown events, 216–217

onkeypress events, 218

onkeyup events, 218

online pastebins, 495

online resources, 490–492, 494–496

onload events, 14, 197–199

onmousedown events, 204–206

onmousemove events, 207–209

onmouseout events, 14, 90, 210

onmouseover events, 14, 90, 210, 353

onmouseup events, 206, 211

onmove events, 201

onpagehide events, 138

onpageshow events, 138

onreadystatechange events, 333

onreset events, 212

onresize events, 200–201

onselect events, 14, 212

onsubmit events, 14, 212

onunload events, 14, 136, 200

open() method, 127, 130, 333

Opera, 58, 373, 494

operators

arithmetic, 15

assignment, 16

comparison, 16

defined, 15

regular expression, 171

<option> tags, 134

or (|) operator, 70

or (||) operator, 16, 74

outline-style menus, 285

P

pageCount array, 123

page hit counters, 230

page properties (CSS), 488

paragraphs, 245

parameters, passing, 35, 55

parentheses

in functions, 25, 28

in loops, 51

in methods, 12

in regular expressions, 174

parseInt() method, 228, 240

parse() method, 269

passing information, 55–56

password-checking script, 142, 147–148

pastebins, 495

period (.), 12

Perl, 7, 172, 176

Perl and CGI for the World Wide Web: Visual QuickStart Guide, 176

phone numbers, formatting/validating, 189–191

Photoshop, 306, 444

PHP, 7, 172

plugins, jQuery, 399, 420–424

plus sign (+), 15, 174

PNG images, 105

pop-up killers, 129

pop-up menus, 140–141

pop-up windows, 129, 197, 200, 203, 278

postal codes, validating, 162–165

ppk on JavaScript, 493

programming languages, 2, 3, 172

progressive enhancement, 42

Pro JavaScript Techniques, 493

prompt() method, 35

properties

combining with objects/methods, 12–13

defined, 12

distinguishing from methods, 12

reference

CSS, 483–488

JavaScript, 465–476

for RegExp object, 186

Prototype, 373

pseudo-classes (CSS), 482

pseudo-elements (CSS), 482

pull-down menus, 289–296

Python, 172

Q

question mark (?), 175

QuirksMode blog, 492

quotes, in bookmarklets, 432

R

radio buttons, 156–158

random images, 111–114

random numbers, 54, 126, 347

ready() method, 366

readyState property, 334

redirection, 21, 37–38

RegExp object, 171, 186, 472

regular expressions, 171–193

alternate names for, 171

defined, 171

extracting strings with, 180–182

formatting strings with, 183–191

geekiness of, 172

modifiers for, 177

purpose of, 171

replacing elements with, 192–193

sorting strings with, 187–188

special characters for, 177

validating email addresses with, 173–176

validating file names with, 178–179

validating strings with, 189–191

validating URLs with, 178–179

ways of using, 171, 172

replaceChild() method, 254

replace() method, 117, 186

reserved words, 477–480

Resig, John, 376, 493

resizable dialogs, 387

resizeTo() method, 452

resizing windows, 452

resources

books

Ajax, 493

CGI programs, 176

CSS, 2, 481

Dreamweaver, 138

HTML, 2

JavaScript, 493

Perl, 176

videos, 493

Web sites

Ajaxian, 492

Bare Bones Software, 20

bit.ly, 449

bookmarklets.com, 427

Dojo, 373

ECMA International, 457

Firebug Debugger, 494

Flickr, 325, 339–345, 349–352

Google Maps Mania (googlemapsmania.blogspot.com), 10

JavaScript Center, 490

JavaScript World (javascriptworld.com), 2, 489

jQuery (jquery.com), 376

JSBin, 495

JScript Language, 491

JSFiddle, 495

JSHint, 494

lynda.com, 493

Mozilla Hacks, 491

Prototype, 373

QuirksMode, 492

Resig, John (ejohn.org), 376

Stack Exchange (stackexchange.com), 496

Stack Overflow (stackoverflow.com), 496

Surfin’ Safari, 491

tinyurl.com, 449

Twitter (twitter.com), 411-419, 449

Venkman Debugger, 490–491

W3C validation tool (validator.w3.org), 17, 450

Web Standards Project (webstandards.org), 42

Wikipedia, 373

Willison, Simon (simonwillison.net), 199

YUI, 373

responseText property, 335

responseXML property, 335

RGB-to-hex converter, 444–445

rollovers, 83–103

browser considerations, 84, 90

building three-state, 91–92

creating more effective, 85–89

creating simple, 83–84

defined, 6, 81

making multiple links change single rollover, 96–98

preparing images for, 90

triggering from text links, 93–95

working with multiple, 99–103

RSS feeds, 340

S

Safari

and alert boxes, 32

blog, 491

and browser detection, 58

creating bookmarklets in, 427

and DOM-2, 242

and ECMAScript, 458

and external JavaScript files, 28

and iPhone, 80

and JavaScript toolkits, 373

and onkeydown events, 217

and onload events, 136, 138

and page caching, 136, 138

performing word lookups in, 436–437

viewing document’s tree structure in, 13

window defaults, 130

sample scripts

Ajax

auto-completing fields, 357–362

parsing server data, 339–345, 349–352

previewing links, 353–356

refreshing server data, 346–348

requesting/reading server data, 331–338, 349–352

bookmarklets

changing page’s styles, 433–435

converting kilometers to miles, 446

converting RGB values to hex, 444–445

creating in Firefox, 427

creating in Internet Explorer, 428–431

creating in Safari, 427

displaying ISO Latin characters, 441–443

looking up words, 436–438

mailing Web pages, 451

resetting page background, 432

resizing pages, 452

shortening URLs, 449

using JavaScript calculator, 447–448

validating pages, 450

viewing images, 439–440

cookies

counting cookies, 228–230

deleting cookies, 231–232

displaying “New to You” message, 235–240

handling multiple cookies, 233–234

reading cookies, 225

setting cookies, 221–224

showing cookies, 226–227

cycling banners

adding links, 106–107

creating, 104–105

dynamic pages

converting 24-hour to 12-hour time, 272–273

creating countdown, 274–277

customizing message for time of day, 265

displaying dates by time zone, 266–271

hiding/displaying layers, 279–280

identifying weekday vs. weekend, 264

moving objects, 281

putting current date on Web page, 262–263

event handlers

checking for double clicks with ondblclick, 210

controlling window stacking with onfocus, 202

fixing Netscape dynamic content redraw bug with onresize, 200–201

hiding code with onmousedown, 204–206

preventing wayward field entries with onfocus, 215

setting multiple onload attributes, 196–199

triggering slide change with onkeydown, 216–217

using onblur to force field entry, 213–214

using onblur to keep window in front, 203

using onblur to trigger action when user leaves field, 214

using onmousemove to display eyeballs that follow user, 207–209

form handling

changing menus dynamically, 140–141

checking one field against another, 147–148

creating select-and-go menu, 135–138

identifying problem fields, 149–150

making fields required, 142–146

making sure user picks radio button, 156–158

setting field value automatically, 159–161

validating email addresses, 166–170, 173–176

validating multi-element form, 152–155

validating zip codes, 162–165

frames

creating content for iframes, 121–122

keeping pages out of frames, 117

loading dynamic iframes, 123–124

loading iframes with JavaScript, 120

setting target for frames, 118–119

sharing functions between documents, 125–126

“Hello, Cleveland!”, 2

“Hello, world!”, 23, 27, 29–30, 426

images

cycling with random start, 113–114

displaying as slideshow, 108–110

displaying random, 111–112

rollover, making multiple links change single, 96–98

rollovers, building three-state, 91–92

rollovers, creating more effective, 85–89

rollovers, creating simple, 83–84

rollovers, triggering from text links, 93–95

rollovers, working with multiple, 99–103

JavaScript applied

adding pull-down menus, 289–292

allowing user to switch between style sheets, 315–324

enhancing pull-down menus, 293–296

generating bar graph, 306–314

generating silly names, 301–305

showing captions in slideshows, 297–300

using sliding menus, 286–288

JavaScript basics

alerting users, 31–32

commenting scripts, 29–30

confirming user choice, 33–34

enclosing script in <script> and </script> tags, 23–24

enhancing links, 39–40

handling errors, 46–47

prompting users, 35–36

redirecting users with link, 37–38

referencing external JavaScript files, 26–28

using conditionals, 33–34, 43–45

JavaScript language essentials

applying styles with JavaScript, 68–70

calling scripts multiple ways, 66–67

checking states, 71–74

detecting objects, 57–58

passing values to functions, 55–56

returning values from functions, 61–62

updating arrays, 62–63

using arrays, 59–60

using do/while loops, 64–65, 78

using for loops, 50–54

using string arrays, 77–80

jQuery

adding calendar to page, 403–407

adding jQuery to page, 365

adding user interaction/updates, 369–373

audio player plugin, 420–424

auto-completing fields, 374–375

creating accordion menus, 382–385

creating smarter dialogs, 386–387

creating sortable tables, 393–396

dragging/dropping elements, 408–410

highlighting new elements, 378–381

striping tables, 390–392

updating page, 368

objects and DOM

adding text nodes, 244–245

deleting text nodes, 246–250

inserting nodes, 251–253

replacing nodes, 254–256

using object literals, 258–260

regular expressions

capitalizing names, 183–185

extracting strings, 180–182

formatting/sorting strings, 187–188

formatting strings, 183–185

formatting/validating strings, 189–191

replacing page elements, 192–193

sorting names, 187–188

validating email addresses, 173–176

validating file names, 178–179

validating phone numbers, 189–191

validating URLs, 178–179

windows

loading different contents into, 131–132

opening new, 127–129

sans-serif fonts, 315, 318

scope, variable, 36, 435

screen size, 452

script errors, 129

scripting, unobtrusive, 41, 42

scripting languages, 2, 5

scripts. See also sample scripts

allowing users to run, 66–67

anticipating user actions in, 14

calling functions in, 25

calling multiple ways, 66–67

defined, 2

how Web browsers handle, 2

internal vs. external, 26

putting comments in, 29–30

testing, 130

triggering when page loads, 14

using external, 26–28

where to put, 23

writing your first, 23

<script> tags

adding attributes to, 24

in book’s sample scripts, 24

enclosing scripts in, 23

language attribute of, 24

and page hijacking, 117

script text and, 2

where to put, 2

search-and-replace feature, 50

search() method, 186

security problems, Internet Explorer, 431

security settings, browser, 129

select-and-go menus, 135–138

selected attribute, 134

<select> tags, 134

semantic chunks, breaking content into, 18

semicolon (;), 24, 173, 425, 435

serif fonts, 315, 318

server data

parsing, 339–345, 349–352

refreshing, 346–348

requesting/reading, 331–338, 349–352

server machines, writing of files on, 7

server-side programs, 6, 241, 330

setTimeout() method, 199, 346

silly name generator, 301–305

simonwillison.net, 199

size attribute, 134

slash (/), 122, 173

slideshows

building wraparound, 108–110

enabling dragging/dropping for, 408–410

showing captions in, 297–300

sliding menus, 286–288

sorting tables, 393–396

spacer GIFs, 18, 113

<span> tags, 18

special characters, 174, 177, 441–443

speech synthesis, 481

split() method, 186, 222, 223

square root calculator, 46–47

src attribute, 22, 26, 82, 116

srcElement property, 69

Stack Exchange, 496

Stack Overflow, 496

standards. See Web standards

state names, auto-completing, 357–362, 374–375

SteveNote Bingo, 80

string arrays, 77–80

string methods, 186

strings, 180–191

comparing, 16

defined, 15

extracting, 180–182

formatting, 183–191

returning, from functions, 61

sorting, 187–188

syntax for, 117

validating, 171, 189–191

striped tables, 390–392

style attribute, 70

styles. See also CSS

applying, with JavaScript, 68–70

changing, with bookmarklet, 433–435

style sheet switcher, 315–324

Styling Web Pages with CSS: Visual QuickProject Guide, 481

submit buttons, 133, 139, 142, 212

substring() method, 237, 240

Sun Microsystems, 3

Surfin’ Safari blog, 491

switch/case statements, 43–45, 276

syntax, dot, 12–13, 196

syntax errors, 129

T

tabbed browsing settings, 129

table-based layouts, 18

table properties (CSS), 487

tables

sorting, 393–396

striping, 390–392

viewing page’s images in, 439–440

<table> tags, 49

tabular data, 49, 390. See also tables

tag-along dots script, 209

tagName, 87, 90

tags. See also specific tags

basic, 22

form, 134

frame, 116

image, 82

table, 49

target attribute, 118–119

<td> tags, 49

terminology

DOM 2, 243

JavaScript, 42

node manipulation, 242–243

testing scripts, 130

test() method, 186

textContent property, 336

text editors, 20

text links, triggering rollovers from, 93–95

TextMate, 172

text nodes, 244–250

adding, 244–245

defined, 13, 243

deleting, 246–250

text properties (CSS), 484

text property, 336

Text Wrangler, 20

ThemeRoller, 400–402

themes, jQuery, 385, 388–389

thesaurus-lookup script, 436–438

this keyword, 41, 260

three-state rollovers, 91–92, 192

throw statement, 46, 47

<th> tags, 49

Thunderbird, 491

time

adding AM/PM to, 271, 273

converting 24-hour to 12-hour, 272–273

customizing messages for, 265

dealing with Daylight Savings Time, 271

time server, 271

time zone, displaying dates by, 266–271

tinyurl.com, 449

<title> tags, 22

toggle() method, 380

toolkits, JavaScript. See frameworks, JavaScript

toSource() method, 186

toString() method, 186

transparent GIFs, 90

tree structure, 13, 243

<tr> tags, 49

true/false values, 15, 57, 70

try statement, 47

tutorials

JavaScript, 493

jQuery, 376

Twitter, 411–419, 449

type attribute, 24, 134

U

<ul> tags, 292

Universal Time, 266, 283

Unix, 3, 20

unobtrusive scripting, 41, 42

unordered lists, 292

URLs

shortening, 449

updates to this book’s, 489

validating, 178–179

URL-shortening services, 449

user interface properties (CSS), 488

users

alerting, 31–32

allowing control of scripts by, 66–67

confirming choices of, 33–34

prompting for response, 35–36

redirecting with links, 37–38

UT, 266

UTC, 266, 283

V

validating

email addresses, 166–170, 173–176

file names, 178–179

forms, 151–155, 212

JavaScript, 494

phone numbers, 190–191

strings, 171, 189–191

URLs, 178–179

vs. verifying, 169

Web pages, 17, 450

zip codes, 162–165

validator.w3.org, 17, 450

value attribute, 134

valueOf() method, 186

values

adding, 15

assigning to variables, 16

binary, 70, 71

checking variables against multiple, 43

comparing, 16, 70

converting kilometers to miles, 446

converting RGB to hexadecimal, 444–445

defined, 15

literal, 16

passing to functions, 55–56

types of, 15

var keyword, 35, 36

variables

assigning values to, 16

checking against multiple values, 43

comparing values of, 16

declaring, 35

defined, 15

defining scope of, 36, 435

naming, 15, 182, 479

use of equals sign with, 15

Venkman Debugger, 490–491

verifying email addresses, 169

video training resources, 493

videos

Ajax Essential Training, 493

JavaScript Essential Training, 493

Vista. See Windows Vista

visual effects properties (CSS), 487

visual formatting properties (CSS), 486

visually impaired users, 296

void() method, 432, 435

W

W3C

deprecation of attributes by, 24

and DOM-2, 242

and DOM-3, 243

and DOM scripting, 42

and innerHTML property, 28

and node manipulation, 241, 242, 243

validation tool, 17, 450

Web

browsers. See Web browsers

dramatic changes in, 325

dynamic nature of, 1

standard layout language for, 17

standards. See Web standards

Web 2.0, 328, 343, 377

Web-based email, 10

Web-based slideshows, 408–410

Web browsers. See also specific browsers

and Ajax, 329, 348

and alert boxes, 32

and browser detection, 58

and caching, 348

and case-sensitivity, 480

and cookies, 219–220

and Daylight Savings Time, 271

and DOM, 242, 438

and ECMAScript, 458

and event handlers, 69

and external JavaScript files, 28

and JavaScript toolkits, 373

and JavaScript versions, 454

performing word lookups in, 436–438

and pop-up windows, 129

and resizing of images, 90

and rollovers, 84, 90

and security problems, 431

testing scripts in different, 130

viewing document tree structure in, 13

and Year 2000 Problem, 277

WebKit, 491

weblogs

Ajaxian, 492

jQuery, 376

jScript, 491

Mozilla Hacks, 491

QuirksMode, 492

Surfin’ Safari, 491

Web page hit counters, 230

Web pages. See also Web sites

adding interactivity to, 1, 6, 68–70, 369–373

adding visual interest to, 81

changing background color for, 432, 433–435

changing styles for, 433–435

characteristics of effective, 261

mailing, 451

preventing hijacking of, 117

reading information from opened, 7

reloading part of, 67

shortening URLs for, 449

standards-compliant, 17, 450

tree structure for, 13, 243

unobtrusive scripting of, 41, 42

validating, 17, 450

viewing all images on, 439–440

Web sites. See also Web pages

alerting users to new content on, 235–240

presenting slideshows on, 108

for specific topics/companies. See resources

Web standards

and browser DOMs, 438

and JavaScript toolkits, 373

validating pages for compliance with, 17, 450

Web Standards Project, 42

while statements, 64–65

width attribute, 82

Wikipedia, 373

Willison, Simon, 199

window event handlers, 196–203

onabort, 201

onblur, 203

onerror, 201

onfocus, 202

onload, 14, 197–199

onmove, 201

onresize, 200–201

onunload, 14, 136, 200

Windows

and Java, 3

and JScript, 455

text editor, 20

Vista, 431

XP Service Pack 2, 431

windows, 125–132

adding parameters to, 130

alert, 31–32

closing, 7

elements of standard browser, 127

how JavaScript deals with, 115

importance of, 115

loading different contents into, 131–132

opening new, 127–129

pop-up, 197, 200, 203

sharing functions between, 125–126

Word, Microsoft. See Microsoft Word

WYSIWYG editors, 20, 41, 138

X

XHTML, and target attribute, 118, 119

XHTML Strict, 118

XML, 9, 327

XMLHttpRequest object, 9, 327, 331, 332, 338, 399

Y

Year 2000 Problem, 277

yellow fade, 377, 378

YUI (Yahoo! User Interface Library), 373

Z

zebra-striped tables, 390–392

z-index, 278

zip codes, 162–165

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.160.181