index.fm Page 709 Wednesday, May 28, 2003 12:01...

22
709 INDEX Symbols = (assignment operator), 56 \ (backslash), 33 \b (backspace), 33 \" (double quotation mark), 32 \e (escape), 33 \f (form feed), 33 << (left shift) operator, 81 \n (newline), 33 + sign, 42-44 \r (return), 33 >> (sign-propagating right shift) operator, 82 \' (single quotation mark), 32 \t (tab), 32 \uXXXX escape sequence, 33 \XXX escape sequence, 33 \xXX escape sequence, 33 >>>> (zero-fill right shift) operator, 82 A Absolute positioning, 531–36 Access logs and status codes, 620–21 Action attribute, 263 ActiveX controls, 210–11 <a href> tag, 340 Alert dialog box, 47–50 Alert() method, 47–50 Alphabetic characters, checking for, 321–24 Alphabetic data, checking for, 451–52 Alternation, 441–46 Anchors, 435–41 Anchors object, 345–46 Animation, 575–78 Arguments: described, 112 override argument, 692 passing, 114–15 Arithmetic operators, 60–61 Array objects: associative arrays, 151, 156 concat() method, 159 creating and populating an array simultaneously, 155 declaring, 152–56 elements of, 151 length property, 157 for loop used to populate, 154 methods, 158–65 multidimensional arrays, 151 new constructor used to declare, 152–53 overview, 151 pop() method, 160 properties of, 157–58 push() method, 161 shift() method, 162 slice() method, 163–64 splice() method, 164–65 unshift() method, 162 Assignment: autodecrement (––) operator, 64 autoincrement (++) operator, 64 Assignment operator (=), 56 Associative arrays, 151, 156 Associativity rules for operators, 56–59

Transcript of index.fm Page 709 Wednesday, May 28, 2003 12:01...

Page 1: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

709

INDEX

Symbols= (assignment operator), 56\ (backslash), 33\b (backspace), 33\" (double quotation mark), 32\e (escape), 33\f (form feed), 33<< (left shift) operator, 81\n (newline), 33+ sign, 42-44\r (return), 33>> (sign-propagating right shift) operator, 82\' (single quotation mark), 32\t (tab), 32\uXXXX escape sequence, 33\XXX escape sequence, 33\xXX escape sequence, 33>>>> (zero-fill right shift) operator, 82

AAbsolute positioning, 531–36Access logs and status codes, 620–21Action attribute, 263ActiveX controls, 210–11<a href> tag, 340Alert dialog box, 47–50Alert() method, 47–50Alphabetic characters, checking for, 321–24Alphabetic data, checking for, 451–52Alternation, 441–46Anchors, 435–41Anchors object, 345–46

Animation, 575–78Arguments:

described, 112override argument, 692passing, 114–15

Arithmetic operators, 60–61Array objects:

associative arrays, 151, 156concat() method, 159creating and populating an array simultaneously,

155declaring, 152–56elements of, 151length property, 157for loop used to populate, 154methods, 158–65multidimensional arrays, 151new constructor used to declare, 152–53overview, 151pop() method, 160properties of, 157–58push() method, 161shift() method, 162slice() method, 163–64splice() method, 164–65unshift() method, 162

Assignment:autodecrement (––) operator, 64autoincrement (++) operator, 64

Assignment operator (=), 56Associative arrays, 151, 156Associativity rules for operators, 56–59

index.fm Page 709 Wednesday, May 28, 2003 12:01 PM

Page 2: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

710 Index

Attributes, 127action attribute, 263assigning, 482–85bottom attribute, 533–36domain name attribute, 481expiration date attribute, 480–81get attribute, 263language attribute, 20left attribute, 533–36method attribute, 263name attribute, 272, 480overview, 480path attribute, 481post attribute, 263right attribute, 533–36secure attribute, 482src attribute, 20top attribute, 533–36type attribute, 20, 515–18

Autodecrement (––) operator, 64Autoincrement (++) operator, 64

BBackground graphics, 593Background properties, 510–11Backslash (\), 33Bars:

graphics and images, 597menu bars, collapsing, 241–43navigation bars, creating, 238–40toolbars, collapsing, 241–43

Backspace (\b), 33Bitwise operators, 80–83

bitwise shift operators, 81–82overview, 80–83

Bitwise shift operatorsleft shift (<<) operator, 81overview, 81sign-propagating right shift (>>) operator, 82zero-fill right shift (>>>>) operator, 82

Blocks, 93Blur() method, 365–67<BODY> tag, 586Boolean literals, 34–35Border properties, 512–14Bottom attribute, 533–36Break statement, 98, 101, 105–7Browser object model (BOM):

ActiveX controls, 210–11

frames:child frames, 232frame object, 236–37HTML frames, creating, 232–36menu bars, collapsing, 241–43menus, creating, 238–40navigation bars, creating, 238–40overview, 231–32parent window, 232toolbars, collapsing, 241–43top property used to keep Main Window out of

a frame, 240–41location object:

methods, 245new page into frame, loading, 245–47overview, 244properties, 244reload() method, 245replace() method, 245URL of document currently loaded in window,

accessing, 244–45MIME types, 211–13navigator object, 203–13

browser sniffer, 205browser support for, 203Internet Explorer support for, 203name of browser, 205Netscape Navigator support for, 203plug-in object, 207–10plug-ins, detecting, 207–10properties, 203–4version of browser, 205

overview, 201–2window object:

history object, 247–49methods, 215–16opening windows, 216–20open() method, 216–20overview, 214properties, 214–15resizing a window, 220–22screen object, 250–51scrolling in windows, 228–30scrollTo() method, 228–31setInterval() method, 222–27setTimeout() method, 222–26timed events, creating, 222–27

Browsers:compliance, 547–48

index.fm Page 710 Wednesday, May 28, 2003 12:01 PM

Page 3: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

Index 711

cookies, used to remove, 492–93CSS-enhanced browsers, 496name of, 205old or disabled browsers:

examples of a JavaScript-disabled browser, 10–11

examples of a JavaScript-enabled browser, 10–11

hiding from old browsers, 9–11hiding within HTML comments, 9–11and <noscript> tag, 11–12

support for navigator object, 203version of, determining, 205

Browser sniffer, 205Bugs to watch out for, 44Bullets, 597Button input type, 288–89Buttons:

event handlers, 354form events, 377naming forms and buttons, 272–78radio buttons, 311–14submitting fillout forms with button input type,

288–89

CCarpout method, 693–94Case keyword, 98Case sensitivity, 17, 590–91Case statement, 97–100Ceil() method, 175CGI:

CGI.pm moduleadvantages of, 662carpout method, 693–94checkbox() method, 682–85cookies, 696–701defaults() method, 692elements, 676–703fatalsToBrowser method, 693–94function-oriented programming style, 663–64HTTP header methods, 702–3labels, 689–90methods, 676–703object-oriented programming style, 662–63override argument, 692overview, 661popup_menu() method, 685–88, 690–92processing input from forms, 664–76

programming styles, 662–64radio_group() method, 685–88reset() method, 692submit() method, 692textfield() method, 678–82

communication between server and scriptenvironment variables, 622–23HTML file with link to CGI script, 624–26overview, 621–22

finding CGI applications, 621form processing:

creating HTML form, 628–32decoding query string, 639–40decoding query string with Perl, 637–38e-mail, 648–55encoded query string, 636extra path information, 656–58GET method, 633–35, 640–44input types for forms, 627–28Mail::Mailer Perl module, 653–54mailto: protocol, 654–55overview, 626–27parsing form’s input with Perl, 638POST method, 644–48SMTP server, 648–53SSI (Server Side Includes), 658–61

HTML:creating a Web page with, 611–15HTTP headers, 617overview, 611–12, 615–16simple CGI script, 616–19simple HTML document, 612–13tags, 612, 614–15

HTTP server, 606–7HTTP status codes and log files, 607–8log files:

access logs and status codes, 620–21error logs and STDERR, 619–20

overview, 605resources, 581root directory, file URLs and server’s, 611URLs, 609–11

CGI.pm module:advantages of, 662carpout method, 693–94checkbox() method, 682–85cookies, 696–701defaults() method, 692elements, 676–703

index.fm Page 711 Wednesday, May 28, 2003 12:01 PM

Page 4: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

712 Index

CGI.pm module (cont.):fatalsToBrowser method, 693–94function-oriented programming style, 663–64HTTP header methods, 702–3labels, 689–90methods, 676–703object-oriented programming style, 662–63override argument, 692overview, 661popup_menu() method, 685–88, 690–92processing input from forms, 664–76programming styles, 662–64radio_group() method, 685–88reset() method, 692submit() method, 692textfield() method, 678–82

Character class, 419–22Character formatting, 589CharAt() method, 187–88Checkboxes, 314–19Checkbox() method, 682–85Checkbox object:

input devices for forms, programming, 314–19overview, 315properties, 315, 316

Child frames, 232Child nodes, 544Class:

creating a style, 522–23properties, 405–6and prototype object, 145–47

CodingForums, 581Color changed with className property, 560–62Color properties, 504–5Comments, 498

adding, 590block comments, 19single-line comments, 19

Common Gateway Interface. See CGI.Comparison operators:

equality and, 68identity and, 69numbers, comparing, 69–70overview, 67strings, comparing, 70–72

Complex tag, 591Composite data types, 36–37Compound statement, 93Concatenation and variables, 42–44

Concatenation operator, 66–67Concat() method, 159Conditional constructs:

break statement, 98case keyword, 98if/else if statement, 96–97if/else statement, 94–96labels, 98overview, 93–94switch statement, 97–100

Conditional operator, 79–80Confirm dialog box, 53–54Constants, 191–92Constructor method, 401–5Constructor used to create objects, 128–29Contextual selectors, 527–30Continue statement, 101, 105–7Control statements, 105–7Control structures, 93Conversion:

of data types, 83–90of milliseconds, 169–71of numbers, 191–92

Cookie object, 482Cookies:

attributes:assigning, 482–85domain name attribute, 481expiration date attribute, 480–81name attribute, 480overview, 480path attribute, 481secure attribute, 482

browser used to remove, 492–93CGI.pm module, 696–701components of, 479cookie object, 482creating, 482–93deleting, 490–93escape() function, 483–84help with, 493–94HTTP and, 477and Internet Explorer, 478, 492–93and Netscape Navigator, 477–78, 492–93overview, 477–78server, retrieving from, 488–89turning off, 478unescape() function, 483–84

index.fm Page 712 Wednesday, May 28, 2003 12:01 PM

Page 5: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

Index 713

Core objects:Array objects:

associative arrays, 151, 156concat() method, 159creating and populating an array

simultaneously, 155declaring, 152–56elements of, 151length property, 157for loop used to populate, 154methods, 158–65multidimensional arrays, 151new constructor used to declare, 152–53overview, 151pop() method, 160properties of, 157–58push() method, 161shift() method, 162slice() method, 163–64splice() method, 164–65unshift() method, 162

Date object:conversion of milliseconds, 169–71methods, 167–69overview, 165–66prototype property, 171–72

Math object:ceil() method, 175floor() method, 175, 176methods, 173overview, 172Pi, 174power of a number, 174properties, 172–73random() method, 176random number generation, 176–77rounding up and down, 174–76round() method, 175square root, 174

Number object:constants, 191–92conversion of numbers, 191–92formatting numbers, 192–93methods, 191overview, 190–91properties, 190toFixed() method, 192–93

overview, 151

String object:charAt() method, 187–88extraction of substrings from a string, methods

for, 187–88HTML methods, 182–83indexOf() method, 185–87lastIndexOf() method, 185–87length property, 179–80methods, 182–89overview, 177–78position in a string, finding, 184–87properties, 179–81prototype property, 179, 181replace() method, 188–89search and replace methods, 188–89search() method, 188–89splice() method, 187split() method, 187–88string manipulation methods, 184substring() method, 187substr() method, 187–88with keyword, 197

Wrapper objects:Boolean object, 193–94Function object, 195–96Number object, 190–93overview, 177String object, 177–89

Credit card validation:expiration date of card, checking, 464–66length of characters, checking, 464–70Lunh formula and, 470–71overview, 464prefix value, checking, 464–70valid type, checking for, 464–70

CSS:background properties, 510–11border properties, 512–14color properties, 504–5comments, 498CSS-enhanced browsers, 496declaration block, 496–97font properties, 506–7grouping, 498–500how it works, 496–501image properties, 510–11margin properties, 512–14measurement, units of, 500–501overview, 496

index.fm Page 713 Wednesday, May 28, 2003 12:01 PM

Page 6: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

714 Index

CSS (cont.) :properties, 501–14selectors, 496–97style object:

color changed with className property, 560–62

overview, 554–58properties, 555–56text positioned with style property, 558–60

text alignment properties, 508–9

DData types:

composite data types, 36–37conversion of, 83–90overview, 31primitive data types:

Boolean literals, 34–35escape sequences, 32–34null, 36numeric literals, 31–32overview, 31quotes, 32string literals, 32–34typeof operator, 35–36undefined, 36

variables converted to, 40–41Date object:

conversion of milliseconds, 169–71methods, 167–69overview, 165–66prototype property, 171–72

Debugging:errors, 24in Explorer, 28–29functions, 124–25load-time errors, 24logical errors, 24in Netscape, 25–27overview, 24runtime errors, 24tools:

for debugging in Explorer, 28–29javascript: URL protocol, 24–25JavaScript Console (Netscape), 25–27

types of errors, 24Declaration block, 496–97Declaring:

array objects, 152–56

functions, 112–13variables, 38–39

Decoding query string, 639–40Decoding query string with Perl, 637–38Default colors, 593–96Defaults() method, 692Defining functions, 112–13Delimiters, 412–14Dialog boxes:

alert dialog box, 47–50confirm dialog box, 53–54described, 47prompt dialog box, 50–52

<div> tag, 536–37Document object:

forms. See forms.HTML <body> tag attributes, 256JavaScript, using document’s properties in,

259–60methods, 260–63overview, 255–56properties, 256–60write() method, 259–60

Document object model (DOM):animation, 575–78browser compliance, 547–48document object:

forms. See forms.HTML <body> tag attributes, 256JavaScript, using document’s properties in,

259–60methods, 260–63overview, 255–56properties, 256–60write() method, 259–60

DOM Level 1, 253–54dot syntax, 255event handling and, 563–66getElementById() method, 548–50getElementByTagName() method, 550–51hierarchy of, 254–55nodes, 254

child nodes, 544element properties, 547methods, 542–43nodeName property, 544–46nodeType property, 544–46overview, 541–43parent nodes, 544

index.fm Page 714 Wednesday, May 28, 2003 12:01 PM

Page 7: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

Index 715

properties, 542–43scrolling with, 551–54siblings, 543

overview, 253–54, 540visibility, setting, 569–75visibility property

drop-down menus, 569–72overview, 569tool tips, 573–74

W3C and, 253z-index and dynamic positioning, 567–68

Domain name attribute, 481DOM Level 1, 253–54Dot metacharacter, 417–18Dot (.) syntax, 128, 255Double quotation mark (\"), 32Do/while loop, 102–3Drop-down menus, 304–11, 569–72Dynamic HTML (DHTML):

CSS:background properties, 510–11border properties, 512–14color properties, 504–5comments, 498CSS-enhanced browsers, 496declaration block, 496–97font properties, 506–7grouping, 498–500how it works, 496–501image properties, 510–11margin properties, 512–14measurement, units of, 500–501overview, 496properties, 501–14selectors, 496–97style object, 554–62text alignment properties, 508–9

DOM:animation, 575–78browser compliance, 547–48event handling and, 563–66getElementById() method, 548–50getElementByTagName() method, 550–51nodes and, 541–47overview, 540visibility, setting, 569–75z-index and dynamic positioning, 567–68

embedded style sheet:overview, 515

type attribute, 515–18overview, 495style sheets:

class, creating a style, 522–23contextual selectors, 527–30CSS. See Dynamic HTML, CSS.embedded style sheet, 515–18external style sheets, 520–21ID selector, 524–25inline style sheet, 518–19overview, 495positioning elements and layers, 530–40<span> tag, 525–27types of, 515–40

EECMA, 7ECMAScript, 7escape (\e), 33Eich, Brendan, 1Element properties, 547Elements:

of array objects, 151CGI.pm module, 676–703positioning elements and layers

absolute positioning, 531–36bottom attribute, 533–36<div> tag, 536–37left attribute, 533–36overview, 530–31relative positioning, 537–39right attribute, 533–36style sheets, 530–40top attribute, 533–36z-index, 539–40

Elements[] array:forms object, 269–70, 272properties, 272

E-mail:addresses, checking, 324–26, 461–64form processing, 648–55

Embedded style sheet:overview, 515type attribute, 515–18

Embeds object, 346–48Empty fields, checking for, 319–21, 446–48Encoded query string, 636Environment variables, 622–23Equality and comparison operators, 68

index.fm Page 715 Wednesday, May 28, 2003 12:01 PM

Page 8: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

716 Index

Errors:events, 393–94load-time, 24logical, 24logs and STDERR, 619–20runtime, 24

Escape() function, 483–84Escape sequences, 32–34

backslash (\ ), 33backspace (\b), 33double quotation mark (\"), 32escape (\e), 33form feed (\f) , 33newline (\n), 33return (\r), 33single quotation mark (\'), 32tab (\t), 32\uXXXX, 33\XXX, 33\xXX, 33

European Computer Manufacturers Association, 7Eval() method, 89–90Event handlers. See also Events.

for buttons, 354creating, 354–56for documents, 354error events, 393–94event methods, 356–58event object, 394–96form events:

buttons, 377event methods, 380–83list of, 376onBlur event, 383–84onChange event handler, 385–86onClick event, 379–80onFocus event, 383–84onSubmit event, 387–90overview, 376this keyword, 377–78

forms:onClick event, 282–83, 288–89onReset event, 285–86onSubmit event, 283–85this keyword, 287–88

frame events:blur() method, 365–67focus() method, 365–67list of, 361

onBlur event handler, 363–65onFocus event handler, 363–65onLoad event handler, 361–63onload() method, 363onUnLoad event handler, 361–63onunload() method, 363overview, 360–61

as JavaScript methods, 356–60key events:

onKeyDown event, 390–92onKeyPress event, 390–92onKeyUp event, 390–92overview, 390–92

link events, 375–76for links, 354list of, 353–54mouse events:

and images, 370–74list of, 368onMouseOut event handler, 370–71onMouseOver event handler, 370–71overview, 367–68rollovers, 370–71slide show creation, 371–74using, 368–70

overview, 351–54return values, 358–60submitting fillout forms, 281–88window events:

blur() method, 365–67focus() method, 365–67list of, 361onBlur event handler, 363–65onFocus event handler, 363–65onLoad event handler, 361–63onload() method, 363onUnLoad event handler, 361–63onunload() method, 363overview, 360–61

Event methods:event handlers, 356–58form events, 380–83

Event object, 394–96Events. See also event handlers.

example of onClick event, 4–5form events:

buttons, 377event methods, 380–83list of, 376

index.fm Page 716 Wednesday, May 28, 2003 12:01 PM

Page 9: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

Index 717

onBlur event, 383–84onChange event handler, 385–86onClick event, 379–80onFocus event, 383–84onSubmit event, 387–90overview, 376this keyword, 377–78

frame events:blur() method, 365–67focus() method, 365–67list of, 361onBlur event handler, 363–65onFocus event handler, 363–65onLoad event handler, 361–63onload() method, 363onUnLoad event handler, 361–63onunload() method, 363overview, 360–61

function called from, 117–18individually listed and defined, 5key events:

onKeyDown event, 390–92onKeyPress event, 390–92onKeyUp event, 390–92overview, 390–92

link events, 375–76mouse events:

and images, 370–74list of, 368onMouseOut event handler, 370–71onMouseOver event handler, 370–71overview, 367–68rollovers, 370–71slide show creation, 371–74using, 368–70

onAbort event, 5onBlur event, 5, 383–84onChange event, 5onChange event handler, 385–86onClick event, 5, 379–80onError event, 5onFocus event, 5, 383–84onKeyDown event, 390–92onKeyPress event, 390–92onKeyUp event, 390–92onLoad event, 5onMouseOut event, 5onMouseOver event, 5onSubmit event, 5, 387–90

onUnLoad event, 5window events:

blur() method, 365–67focus() method, 365–67list of, 361onBlur event handler, 363–65onFocus event handler, 363–65onLoad event handler, 361–63onload() method, 363onUnLoad event handler, 361–63onunload() method, 363overview, 360–61

Exec() method, 401–2, 404–5Expiration date attribute, 480–81Expiration date of credit card, checking, 464–66Expressions, 55External files, placing JavaScript within, 13External images, 597External style sheets, 520–21Extraction of substrings from a string, methods for,

187–88Extraneous characters in forms, removing, 453–56Extra path information, 656–58

FFatalsToBrowser method, 693–94Flash 5, 597Floating-point numbers, 88–89Floor() method, 175, 176Focus() method, 365–67Font properties, 506–7For/in loop, 105For loop, 104–5, 154Formatting numbers, 192–93Form events:

buttons, 377event methods, 380–83list of, 376onBlur event, 383–84onChange event handler, 385–86onClick event, 379–80onFocus event, 383–84onSubmit event, 387–90overview, 376this keyword, 377–78

Form feed (\f), 33Form processing:

creating HTML form, 628–32decoding query string, 639–40

index.fm Page 717 Wednesday, May 28, 2003 12:01 PM

Page 10: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

718 Index

Form processing (cont.):decoding query string with Perl, 637–38e-mail, 648–55encoded query string, 636extra path information, 656–58GET method, 633–35, 640–44input types for forms, 627–28Mail::Mailer Perl module, 653–54mailto: protocol, 654–55overview, 626–27parsing form’s input with Perl, 638POST method, 644–48SMTP server, 648–53SSI (Server Side Includes), 658–61

Forms:action attribute, 263event handlers:

onClick event, 282–83, 288–89onReset event, 285–86onSubmit event, 283–85this keyword, 287–88

forms object:elements[] array, 269–70, 272forms[] array, 268–69<form> tag elements and properties, 274methods, 272name attribute, 272naming forms and buttons, 272–78overview, 268properties, 271

<form> tag elements and properties, 274get attribute, 263HTML and, 263–64input devices, programming:

checkboxes, 314–19checkbox object, 314–19drop-down menus, 304–11overview, 294password object, 298–301radio buttons, 311–14radio object, 311–14select object, 304–11textarea object, 301–4text object, 294–98

input types, 264–67method attribute, 263naming forms and buttons, 272–78overview, 263post attribute, 263

processing. See form processing.referencing form elements by name, 275–78simple form validation:

alphabetic characters, checking for, 321–24e-mail addresses, checking, 324–26empty fields, checking for, 319–21overview, 319password fields, checking, 326–28

steps used to produce, 264submitting fillout forms:

with button input type, 288–89with event handlers, 281–88image, submitting form with, 280–81with JavaScript, 281–88overview, 279–80pop-up window, displaying form’s content in,

292–93reset() method, 290–91submit() method, 290–91

validation of. See form validation.Forms[] array, 268–69Forms object:

elements[] array, 269–70, 272forms[] array, 268–69methods, 272name attribute, 272overview, 268properties, 271

<form> tag, 274Form validation:

alphabetic data, checking for, 451–52combining functions that validate each field of

form, 471–75credit cards, checking for valid, 464–71e-mail addresses, checking for valid, 461–64empty fields, checking for, 446–48extraneous characters, removing, 453–56non-alphaumeric characters, removing, 456non-digits, removing, 455null fields, checking for, 446–48overview, 446parentheses, removing unwanted, 454phone numbers, checking for valid, 458–61Social Security numbers, checking for valid,

457–58spaces and dashes, removing, 453zip codes, checking for numeric, 448–50

Frame events:blur() method, 365–67

index.fm Page 718 Wednesday, May 28, 2003 12:01 PM

Page 11: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

Index 719

focus() method, 365–67list of, 361onBlur event handler, 363–65onFocus event handler, 363–65onLoad event handler, 361–63onload() method, 363onUnLoad event handler, 361–63onunload() method, 363overview, 360–61

Frame object, 236–37Frames, 602

child frames, 232frame object, 236–37HTML frames, creating, 232–36menu bars, collapsing, 241–43menus, creating, 238–40navigation bars, creating, 238–40overview, 231–32parent window, 232toolbars, collapsing, 241–43top property used to keep main window out of a

frame, 240–41FreewareJava, 581Function-oriented programming style, 663–64Functions:

arguments, 112calling, 112–13debugging, 124–25declaring, 112–13defining, 112–13event, calling a function from a, 117–18<head> tag, placement within, 112invoking, 112–13JavaScript, calling a function from, 119link, calling a function from a, 116–17overview, 111parameters, 114passing arguments, 114–15recursive functions, 123–24return statement, 120–23return values, 120–23<script> tag, placement within, 112typeof operator used to check, 112variables in, scope of, 119–20

GGet attribute, 263GetElementById() method, 548–50GetElementByTagName() method, 550–51

GET method, 633–35, 640–44Global variables, 42Graphics. See Images and graphics.Grouping:

CSS, 498–500metacharacters, 442–43

H<head> tag, 112, 585, 586Headings, 586–87Hello.html file, 15Help with cookies, 493–94Hierarchy of DOM, 254–55History object, 247–49HTML:

basics of, 7–8<body> tag, 7, 256, 586and case sensitivity, 17creating a Web page with, 611–15file with link to CGI script, 624–26and forms, 263–64<form> tag, 4frames, 232–36<head> tag, 7, 585–86hello.html file, 15HTTP headers, 617images, 329–31methods, 182–83overview, 611–12, 615–16<script> tag, 7, 9, 15, 19–20simple CGI script, 616–19simple HTML document, 612–13tags, 612, 614–15using the .html or .htm extensions, 15

HTML documents:case sensitivity, 590–91character formatting, 589comments, adding, 590frames, 602graphics and images:

background graphics, 593bars, 597bullets, 597complex tag, 591default colors, 593–96external images, 597finding, 592Flash 5, 597icons, 597

index.fm Page 719 Wednesday, May 28, 2003 12:01 PM

Page 12: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

720 Index

HTML documents, graphics and images (cont.):inline image, creating, 591sizing and placing, 591–92text alternative for, creating, 592

JavaScript, 601–2linking:

creating a link, 589–90overview, 589to URLs, 590

logical tags, 589metatags, 599–600minimal HTML document:

headings, 586–87lists, 587overview, 586tables, 588tags to separate text, 587

overview, 583–84physical tags, 589source code, 602style sheets, 600–601tags:

<body> tag, 7, 256, 586<head> tag, 7, 585, 586<HTML> tag, 585order of required elements and their tags, 585overview, 584required elements, 585<title> tag, 585

tips for, 602–3troubleshooting, 597–99

<HTML> tag, 585.html or .htm extensions, 15HTTP:

cookies, 477header methods, 702–3headers, 617server, 606–7status codes and log files, 607–8

IIcons, 597Identity and comparison operators, 69ID selector, 524–25If/else if statement, 96–97If/else statements

conditional operator and, 79–80described, 94–96

Image() constructor, 336

Image object:Image() constructor, 336onClick event used to randomly display images,

338–40overview, 331–32preloading images, 336properties, 332randomly displaying images, 338–40rollover with mouse event, 336–38src property, replacing images dynamically with,

333–35Images and graphics:

background graphics, 593bars, 597bullets, 597complex tag, 591default colors, 593–96external images, 597finding, 592Flash 5, 597HTML and, 329–31icons, 597image object:

Image() constructor, 336onClick event used to randomly display

images, 338–40overview, 331–32preloading images, 336properties, 332randomly displaying images, 338–40rollover with mouse event, 336–38src property, replacing images dynamically

with, 333–35inline image, creating, 591JavaScript and, 331–40mouse events, 370–74overview, 328–29properties, 510–11sizing and placing, 591–92submitting form with, 280–81text alternative for, creating, 592

IndexOf() method, 185–87Inheritance, 146–47Initializing variables, 38–39Inline image, 591Inline style sheet, 518–19Input devices for forms, programming

checkboxes, 314–19checkbox object, 314–19

index.fm Page 720 Wednesday, May 28, 2003 12:01 PM

Page 13: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

Index 721

drop-down menus, 304–11overview, 294password object, 298–301radio buttons, 311–14radio object, 311–14select object, 304–11textarea object, 301–4text object, 294–98

Input types for forms, 264–67, 627–28Instance properties, 405–6Internet Explorer:

cookies and, 478, 492–93navigator object, support for, 203versions supported by JavaScript and JScript, 6

Invalid names for variables, 38

JJavaScript, 601–2

attributes. See Attributes.debugging, 24–29

testing with Explorer’s debugging window, 28–29

testing with Netscape’s JavaScript Console, 25–27

testing with the javascript: URL protocol, 24–25

defined, 1–2and events. See Events.example of Web page using, 2external files, placing within, 13generating HTML output, 21–23HTML compared, 3and HTML documents:

script execution, 16where to embed within, 7–8, 15, 19

and images, 331–40Java compared, 2JScript compared, 6methods. See Methods.objects, support for, 127–28and old or disabled browsers:

examples of a JavaScript-disabled browser, 10–11

examples of a JavaScript-enabled browser, 10–11

hiding from old browsers, 9–11hiding within HTML comments, 9–11and <noscript> tag, 11–12

overview, 1–3

placement of, 7–8script setup, 15–30standardizing using ECMAScript, 7strings, 21submitting fillout forms, 281–88syntactical details, 17–20

case sensitivity, 17comments, 19free form and reserved words, 17–18statements and semicolons, 18whitespace, 17

URLs, 340uses for, 3versions of, 6–7, 20

Javascript: URL protocol, 24–25JavaScript Central on Netscape’s devedge site, 581JavaScript Console (Netscape), 25–27JavaScript Planet, 581JScript, 6

KKey events:

onKeyDown event, 390–92onKeyPress event, 390–92onKeyUp event, 390–92overview, 390–92

LLabels, 98, 108–9, 689–90LastIndexOf() method, 185–87Layers:

positioning elements and layers:absolute positioning, 531–36bottom attribute, 533–36<div> tag, 536–37left attribute, 533–36overview, 530–31relative positioning, 537–39right attribute, 533–36style sheets, 530–40top attribute, 533–36z-index, 539–40

Left attribute, 533–36Left shift (<<) operator, 81Length of characters, credit card validation and

checking, 464–70Length property:

array objects, 157String object, 179–80

index.fm Page 721 Wednesday, May 28, 2003 12:01 PM

Page 14: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

722 Index

Link events, 375–76Links:

<a href> tag, 340anchors object, 345–46calling a function from, 116–17creating a link, 589–90embeds object, 346–48JavaScript URLs, 340links object, 341–45overview, 340, 589to URLs, 590

Links object, 341–45Literal notation, 400–401LiveScript. See JavaScript.Load-time errors, 24Local variables, 42Location object:

methods, 245new page into frame, loading, 245–47overview, 244properties, 244reload() method, 245replace() method, 245URL of document currently loaded in window,

accessing, 244–45Log files:

access logs and status codes, 620–21error logs and STDERR, 619–20

Logical AND && operator, 73–74Logical errors, 24Logical NOT ! operator, 76–77Logical operators:

logical AND && operator, 73–74logical NOT ! operator, 76–77logical OR // operator, 75–76overview, 72–73

Logical OR // operator, 75–76Logical tags, 589Loops:

break statement, 101, 105–7continue statement, 101, 105–7control statements, 105–7do/while loop, 102–3for loop, 104–5for/in loop, 105labels, 108–9nested loops, 107–8overview, 101while loop, 101–2

Loosely typed language, JavaScript as, 40–41Lunh formula and credit card validation, 470–71

MMail::Mailer Perl module, 653–54Mailto: protocol, 654–55Margin properties, 512–14Match() method, 408–9Math object:

ceil() method, 175floor() method, 175, 176methods, 173overview, 172Pi, 174power of a number, 174properties, 172–73random() method, 176random number generation, 176–77rounding up and down, 174–76round() method, 175square root, 174

Measurement, units of, 500–501Menu bars, collapsing, 241–43Menus, creating, 238–40Metacharacters:

alternation, 441–46anchors, 435–41capturing, 443–46character class, 419–22clustering, 442–43dot metacharacter, 417–18grouping, 442–43list of, 415–17metasymbols, 422–26overview, 414–17pattern matches, metacharacters to repeat,

426–35quantifiers, 426remembering, 443–46zero-width assertions, 435–41

Metasymbols, 422–26Metatags, 599–600Method attribute, 263Methods, 130–31, 542–43

array objects, 158–65blur() method, 365–67carpout method, 693–94ceil() method, 175CGI.pm module, 676–703

index.fm Page 722 Wednesday, May 28, 2003 12:01 PM

Page 15: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

Index 723

charAt() method, 187–88checkbox() method, 682–85concat() method, 159Date object, 167–69defaults() method, 692defined for an object, 134–39document object, 260–63extraction of substrings from a string, methods

for, 187–88fatalsToBrowser method, 693–94floor() method, 175, 176focus() method, 365–67forms object, 272getElementById() method, 548–50getElementByTagName() method, 550–51HTML methods, 182–83HTTP header methods, 702–3indexOf() method, 185–87lastIndexOf() method, 185–87location object, 245Math object, 173Number object, 191onload() method, 363onunload() method, 363open() method, 216–20password object, 299pop() method, 160popup_menu() method, 685–88, 690–92push() method, 161radio_group() method, 685–88random() method, 176reload() method, 245replace() method, 188–89, 245reset() method, 692round() method, 175scrollTo() method, 228–31search and replace methods, 188–89search() method, 188–89setInterval() method, 222–27setTimeout() method, 222–26shift() method, 162slice() method, 163–64splice() method, 164–65, 187split() method, 187–88string manipulation methods, 184String object, 182–89submit() method, 692substring() method, 187substr() method, 187–88

textarea object, 302textfield() method, 678–82text object, 295toFixed() method, 192–93unshift() method, 162window object, 215–16write(), 21–23writeIn(), 21–23

Microsoft Script Debugger (MSSD), 29MIME types, 211–13Minimal HTML document:

headings, 586–87lists, 587overview, 586tables, 588tags to separate text, 587

Mouse events:and images, 370–74list of, 368onMouseOut event handler, 370–71onMouseOver event handler, 370–71overview, 367–68rollovers, 370–71slide show creation, 371–74using, 368–70

Multidimensional arrays, 151Multiple selects, 309–11Murray, Joan, 603

NName attribute, 272, 480Name of browser, 205Naming forms and buttons, 272–78Navigation bars, creating, 238–40Navigator object, 203–13

browser sniffer, 205browser support for, 203Internet Explorer support for, 203name of browser, 205Netscape Navigator support for, 203plug-in object, 207–10plug-ins, detecting, 207–10properties, 203–4version of browser, 205

Nested loops, 107–8Netscape Navigator:

cookies and, 477–78, 492–93navigator object, support for, 203and <noscript> tags, 11–12

index.fm Page 723 Wednesday, May 28, 2003 12:01 PM

Page 16: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

724 Index

Netscape Navigator (cont.):plug-ins, detecting, 207–10versions supported by JavaScript and JScript, 6

New constructor used to declare array objects, 152–53

New operator, 131New page into frame, loading, 245–47Newline (\n), 33NodeName property, 544–46Nodes, 254

DOM:child nodes, 544element properties, 547methods, 542–43nodeName property, 544–46nodeType property, 544–46overview, 541–43parent nodes, 544properties, 542–43scrolling with, 551–54siblings, 543

NodeType property, 544–46Non-alphaumeric characters, removing, 456Non-digits, removing, 455Null, 36Null fields, checking for, 446–48Null string, 32Number object:

constants, 191–92conversion of numbers, 191–92formatting numbers, 192–93methods, 191overview, 190–91properties, 190toFixed() method, 192–93

Numbers, comparing, 69–70Numeric literals, 31–32

OObject() constructor, 131–32Object literals, 140–41Object models, 128Object-oriented programming style, 662–63Objects:

attributes, 127constructor used to create, 128–29dot (.) syntax, 128for/in loop, 143–45JavaScript support for, 127–28

manipulation of:for/in loop, 143–45prototypes used to extend objects, 145–48with keyword, 141–43

methods defined for, 130–31, 134–39methods defined in constructor, 136–38object models, 128overview, 127–28properties, 127, 129–30, 138–39prototypes used to extend objects, 145–48user-defined objects:

creating, 133methods defined for an object, 134–39new operator, 131Object() constructor, 131–32object literals, 140–41user-defined function used to create, 133

with keyword, 141–43OnBlur event, 383–84OnBlur event handler:

frame events, 363–65window events, 363–65

OnChange event handler, 385–86OnClick event:

form events, 379–80forms, 282–83, 288–89used to randomly display images, 338–40

OnFocus event, 383–84OnFocus event handler, 363–65OnKeyDown event, 390–92OnKeyPress event, 390–92OnKeyUp event, 390–92OnLoad event handler, 361–63Onload() method, 363OnMouseOut event handler, 370–71OnMouseOver event handler, 370–71OnReset event, 285–86OnSubmit event, 283–85, 387–90OnUnLoad event handler, 361–63Onunload() method, 363Opening windows, 216–20Open() method, 216–20Operands, 55Operators:

arithmetic operators, 60–61assignment operator (=), 56associativity rules for, 56–59autodecrement (––) operator, 63–65autoincrement (++) operator, 63–65

index.fm Page 724 Wednesday, May 28, 2003 12:01 PM

Page 17: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

Index 725

bitwise operators, 80–83comparison operators, 67–72concatenation operator, 66–67conditional operator, 79–80logical operators, 72–78overview, 55precedence rules for, 56–59shortcut assignment operators, 62–63special operators, 91

Override argument, 692

PParameters, 114Parentheses, removing unwanted, 454Parent nodes, 544Parent window, 232ParseFloat() method, 88–89ParseInt() method, 85–87Parsing form’s input with Perl, 638Passing arguments, 114–15Password fields, checking, 326–28Password object, 298–301Path attribute, 481Pattern matches, metacharacters to repeat, 426–35Phone numbers, checking for valid, 458–61Physical tags, 589Pi, 174Placement of JavaScript, 7–8Plug-in object, 207–10Plug-ins, detecting, 207–10plus sign (+):

concatenation of variable and strings with, 42–44as numeric operator, 43as string operator, 42–43

Pop() method, 160Popup_menu() method, 685–88, 690–92Pop-up window, displaying form’s content in,

292–93Position in a string, finding, 184–87Positioning elements and layers:

style sheets:absolute positioning, 531–36bottom attribute, 533–36<div> tag, 536–37left attribute, 533–36overview, 530–31relative positioning, 537–39right attribute, 533–36top attribute, 533–36

z-index, 539–40Post attribute, 263POST method, 644–48Power of a number, 174Precedence rules, 56–59Prefix value, checking, 464–70Preloading images, 336Primitive data types:

Boolean literals, 34–35conversion methods:

eval() method, 89–90parseFloat() method, 88–89parseInt() method, 85–87

escape sequences, 32–34null, 36numeric literals, 31–32overview, 31quotes, 32string literals, 32–34typeof operator, 35–36undefined, 36

Processing input from forms, 664–76Programming styles, 662–64Prompt dialog box, 50–52Prompt() method, 50–52Properties, 127, 129–30, 501–14, 542–43, 555–56

array objects, 157–58color changed with className property, 560–62document object, 256–60forms object, 271image object, 332length property, 157, 179–80location object, 244Math object, 172–73navigator object, 203–4nodeName property, 544–46nodeType property, 544–46Number object, 190password object, 299prototype property, 171–72, 179, 181RegExp() object, 405–8src property, replacing images dynamically with,

333–35String object, 179–81textarea object, 302text object, 295text positioned with style property, 558–60top property used to keep main window out of a

frame, 240–41

index.fm Page 725 Wednesday, May 28, 2003 12:01 PM

Page 18: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

726 Index

Properties (cont.):visibility property

drop-down menus, 569–72overview, 569tool tips, 573–74

window object, 214–15Prototype object:

class and, 145–47extending, 147–48inheritance and, 146–47overview, 145

Prototype property:Date object, 171–72String object, 179, 181

Push() method, 161

QQuantifiers, 426Quotes, 32

RRadio buttons, 311–14Radio_group() method, 685–88Radio object:

input devices for forms, programming, 311–14methods, 312–13overview, 311–12properties, 312

Randomly displaying images, 338–40Random() method, 176Random number generation, 176–77Recursive functions, 123–24Referencing form elements by name, 275–78RegExp() object:

class properties, 405–6exec() method, 401–2, 404–5instance properties, 405–6overview, 401–2properties, 405–8test() method, 401–4

Regular expressions:constructor method, 401–5creating, 400–414form validation:

alphabetic data, checking for, 451–52combining functions that validate each field of

form, 471–75credit cards, checking for valid, 464–71e-mail addresses, checking for valid, 461–64

empty fields, checking for, 446–48extraneous characters, removing, 453–56non-alphaumeric characters, removing, 456non-digits, removing, 455null fields, checking for, 446–48overview, 446parentheses, removing unwanted, 454phone numbers, checking for valid, 458–61Social Security numbers, checking for valid,

457–58spaces and dashes, removing, 453zip codes, checking for numeric, 448–50

literal notation, 400–401metacharacters:

alternation, 441–46anchors, 435–41capturing, 443–46character class, 419–22clustering, 442–43dot metacharacter, 417–18grouping, 442–43list of, 415–17metasymbols, 422–26overview, 414–17pattern matches, metacharacters to repeat,

426–35quantifiers, 426remembering, 443–46zero-width assertions, 435–41

overview, 399–400RegExp() object:

class properties, 405–6exec() method, 401–2, 404–5instance properties, 405–6overview, 401–2properties, 405–8test() method, 401–4

search patterns, options used for modifying, 400string methods using, 408–14String object

match() method, 408–9overview, 408replace() method, 410–11, 453–56search() method, 409–10split() method, 412–14

testing, 401–5Relative positioning, 537–39Reload() method, 245

index.fm Page 726 Wednesday, May 28, 2003 12:01 PM

Page 19: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

Index 727

Replace() method:location object, 245String object, 188–89, 410–11, 453–56

Required elements for tags, 585Reserved words, 17–18Reset() method:

CGI.pm module, 692submitting fillout forms, 290–91

Resizing a window, 220–22Return (\r), 33Return statement, 120–23Return values, 120–23, 358–60Right attribute, 533–36Rollovers, 370–71Rollover with mouse event, 336–38Root directory, file URLs and server’s, 611Rounding numbers up and down, 174–76Round() method, 175Runtime errors, 24

SScreen object, 250–51Script execution, 16Script setup:

generating HTML, 21–23strings, 21writeIn() method, 21–23write() method, 21–23

HTML document and:generally, 15hello.html file, 15script execution, 16

syntax issues:case sensitivity, 17comments, 19reserved words, 17–18<script> tag, 19–20semicolons, 18statements, 18whitespace, 17

<script> tag, 19–20, 112Scrolling in windows, 228–30, 551–54ScrollTo() method, 228–31Search and replace methods, 188–89Search() method, 188–89, 409–10Search patterns, options used for modifying, 400Secure attribute, 482Select object:

input devices for forms, programming, 304–11

methods, 305multiple selects, 309–11overview, 304properties, 304–5

Selectors, 496–97Semicolons, 18Server:

communication between server and script:environment variables, 622–23HTML file with link to CGI script, 624–26overview, 621–22

cookies retrieved from, 488–89HTTP server, 606–7root directory, file URLs and server’s, 611SMTP server, 648–53SSI (Server Side Includes), 658–61

SetInterval() method, 222–27SetTimeout() method, 222–26Shift() method, 162Shockwave Flash, checking for, 208Shortcut assignment operators, 62–63Siblings, 543Sign-propagating right shift (>>) operator, 82Simple CGI script, 616–19Simple HTML document, 612–13Single quotation mark (\' ), 32Sizing and placing graphics and images, 591–92Slice() method, 163–64Slide show creation, 371–74SMTP server and form processing, 648–53Social Security numbers, checking for valid, 457–58Source code, 602Spaces and dashes in forms, removing, 453<span> tag, 525–27Special operators, 91Splice() method:

array objects, 164–65String object, 187

Split() method, 187–88, 412–14Square root, 174Src property, replacing images dynamically with,

333–35SSI (Server Side Includes), 658–61Statements, 18Stein, Lincoln, 661String literals, 32–34String manipulation methods, 184String object:

charAt() method, 187–88

index.fm Page 727 Wednesday, May 28, 2003 12:01 PM

Page 20: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

728 Index

String object (cont.):extraction of substrings from a string, methods

for, 187–88HTML methods, 182–83indexOf() method, 185–87lastIndexOf() method, 185–87length property, 179–80match() method, 408–9methods, 182–89overview, 177–78, 408position in a string, finding, 184–87properties, 179–81prototype property, 179, 181replace() method, 188–89, 410–11, 453–56search and replace methods, 188–89search() method, 188–89, 409–10splice() method, 187split() method, 187–88, 412–14string manipulation methods, 184substring() method, 187substr() method, 187–88with keyword, 197

Strings, 21bugs to watch out for, 44comparing, 70–72concatenation of, 21, 34conversion to numbers, 85–87, 89–90eval() method used to convert strings to numbers,

89–90parseInt() method used to convert strings to

numbers, 85–87using quotes with, 21

Style object, 554–62CSS:

color changed with className property, 560–62

overview, 554–58properties, 555–56text positioned with style property, 558–60

Style sheets, 600–601CSS. See CSS.overview, 495positioning elements and layers

absolute positioning, 531–36bottom attribute, 533–36<div> tag, 536–37left attribute, 533–36overview, 530–31relative positioning, 537–39

right attribute, 533–36top attribute, 533–36z-index, 539–40

types of, 515–40Submit() method:

CGI.pm module, 692submitting fillout forms, 290–91

Submitting fillout forms:with button input type, 288–89with event handlers, 281–88image, submitting form with, 280–81with JavaScript, 281–88overview, 279–80pop-up window, displaying form content in,

292–93reset() method, 290–91submit() method, 290–91

Substring() method, 187Substr() method, 187–88Switch statement, 97–100Syntax issues:

case sensitivity, 17comments, 19reserved words, 17–18<script> tag, 19–20semicolons, 18statements, 18whitespace, 17

TTab (\t), 32Tables, 588Tags:

<BODY> tag, 586<HEAD> tag, 585, 586HTML, 612, 614–15<HTML> tag, 585order of required elements and their tags, 585overview, 584required elements, 585to separate text, 587<TITLE> tag, 585

Test() method, 401–4Text alignment properties, 508–9Text alternative for graphics and images, creating,

592Textarea object, 301–4Textfield() method, 678–82Text object, 294–98

index.fm Page 728 Wednesday, May 28, 2003 12:01 PM

Page 21: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

Index 729

Text positioned with style property, 558–60This keyword, 287–88, 377–78Timed events, creating, 222–27<TITLE> tag, 585ToFixed() method, 192–93Toolbars, collapsing, 241–43Tool tips, 573–74Top attribute, 533–36Top property used to keep main window out of a

frame, 240–41Troubleshooting, 597–99Turning off cookies, 478Type attribute, 515–18Typeof operator, 35–36, 112

UUnescape() function, 483–84Unshift() method, 162URLs, 244–45, 609–11User-defined function, 133User-defined objects:

creating, 133methods defined for an object, 134–39new operator, 131Object() constructor, 131–32object literals, 140–41user-defined function used to create, 133

\uXXXX escape sequence, 33

VValidation of forms:

alphabetic characters, checking for, 321–24e-mail addresses, checking, 324–26empty fields, checking for, 319–21overview, 319password fields, checking, 326–28

Valid names for variables, 37–38Valid type of credit card, checking for, 464–70Variables:

bugs to watch out for, 44concatenation and, 42–44conversion to data types, 40–41declaring, 38–39global variables, 42initializing, 38–39invalid names for, 38local variables, 42loosely typed language, JavaScript as, 40–41overview, 37

scope of, 42, 119–20valid names for, 37–38

Version of browser, 205Versions of JScript, 6Visibility, setting, 569–75Visibility property:

drop-down menus, 569–72overview, 569tool tips, 573–74

WW3C and DOM, 253Web resources, 581While loop, 101–2Whitespace, 17Window events:

blur() method, 365–67focus() method, 365–67list of, 361onBlur event handler, 363–65onFocus event handler, 363–65onLoad event handler, 361–63onload() method, 363onUnLoad event handler, 361–63onunload() method, 363overview, 360–61

Window object:history object, 247–49methods, 215–16opening windows, 216–20open() method, 216–20overview, 214properties, 214–15resizing a window, 220–22screen object, 250–51scrolling in windows, 228–30scrollTo() method, 228–31setInterval() method, 222–27setTimeout() method, 222–26timed events, creating, 222–27

With keyword, 197World Wide Web Consortium, 253Wrapper objects:

Boolean object, 193–94Function object, 195–96Number object, 190–93overview, 177String object, 177–89

index.fm Page 729 Wednesday, May 28, 2003 12:01 PM

Page 22: index.fm Page 709 Wednesday, May 28, 2003 12:01 …ptgmedia.pearsoncmg.com/images/0131401629/index/...710 Index Attributes, 127 action attribute, 263 assigning, 482–85 bottom attribute,

730 Index

WriteIn() method, 21–23

Write() method, 21–23, 259–60

X\XXX escape sequence, 33

\xXX escape sequence, 33

ZZero-fill right shift (>>>>) operator, 82Zero-width assertions, 435–41Z-index:

described, 539–40and dynamic positioning, 567–68

Zip codes, checking for numeric, 448–50

index.fm Page 730 Wednesday, May 28, 2003 12:01 PM