Sams Teach Yourself JavaScript in 24 Hours [4th Edition] 0672328798, 9780672328794

JavaScript is one of the easiest, most straightforward ways to enhance a website with interactivity. Sams Teach Yourself

583 64 4MB

English Pages 442 [456] Year 2006

Report DMCA / Copyright

DOWNLOAD FILE

Sams Teach Yourself JavaScript in 24 Hours [4th Edition]
 0672328798, 9780672328794

Table of contents :
Cover......Page 1
Contents......Page 6
Part I: Introducing the Concept of Web Scripting and the JavaScript Language......Page 18
Learning Web Scripting Basics......Page 20
How JavaScript Fits into a Web Page......Page 22
Browsers and JavaScript......Page 25
Specifying JavaScript Versions......Page 28
Exploring JavaScript’s Capabilities......Page 29
Alternatives to JavaScript......Page 30
Tools for Scripting......Page 36
Displaying Time with JavaScript......Page 38
Adding JavaScript Statements......Page 39
Creating Output......Page 40
Adding the Script to a Web Page......Page 41
Testing the Script......Page 42
Basic Concepts......Page 50
JavaScript Syntax Rules......Page 55
Using Comments......Page 56
Best Practices for JavaScript......Page 57
Understanding the Document Object Model (DOM)......Page 62
Using Window Objects......Page 64
Working with Web Documents......Page 65
Working with the Location Object......Page 68
Part II: Learning JavaScript Basics......Page 74
Using Variables......Page 76
Understanding Expressions and Operators......Page 80
Data Types in JavaScript......Page 81
Converting Between Data Types......Page 82
Using String Objects......Page 83
Working with Substrings......Page 87
Using Numeric Arrays......Page 89
Using String Arrays......Page 90
Sorting a Numeric Array......Page 92
Using Functions......Page 98
Introducing Objects......Page 103
Using Objects to Simplify Scripting......Page 104
Extending Built-in Objects......Page 107
HOUR 7: Controlling Flow with Conditions and Loops......Page 114
The if Statement......Page 115
Testing Multiple Conditions with If and Else......Page 118
Using Multiple Conditions with switch......Page 120
Using for Loops......Page 122
Using While Loops......Page 124
Working with Loops......Page 125
Looping Through Object Properties......Page 127
Using the Math Object......Page 134
Working with Math Functions......Page 136
Using the with Keyword......Page 138
Working with Dates......Page 139
Using Third-Party Libraries......Page 141
Other Libraries......Page 143
Part III: Learning More About the DOM......Page 150
Understanding Event Handlers......Page 152
Using Mouse Events......Page 157
Using Keyboard Events......Page 162
Using the onLoad and onUnload Events......Page 164
Controlling Windows with Objects......Page 170
Moving and Resizing Windows......Page 173
Using Timeouts......Page 175
Displaying Dialog Boxes......Page 177
Working with Frames......Page 179
The Basics of HTML Forms......Page 186
Using the Form Object with JavaScript......Page 187
Scripting Form Elements......Page 189
Displaying Data from a Form......Page 195
Sending Form Results by Email......Page 197
Style and Substance......Page 204
Defining and Using CSS Styles......Page 205
Using CSS Properties......Page 208
Creating a Simple Style Sheet......Page 211
Using External Style Sheets......Page 213
Controlling Styles with JavaScript......Page 214
The DOM and Dynamic HTML......Page 220
Understanding DOM Structure......Page 221
Creating Positionable Elements (Layers)......Page 223
Working with DOM Nodes......Page 232
Hiding and Showing Objects......Page 235
Modifying Text Within a Page......Page 236
Adding Text to a Page......Page 238
Part IV: Working with Advanced JavaScript Features......Page 246
Scripting Best Practices......Page 248
Reading Browser Information......Page 255
Cross-Browser Scripting......Page 258
Supporting Non-JavaScript Browsers......Page 260
Avoiding Bugs......Page 268
Basic Debugging Tools......Page 271
Creating Error Handlers......Page 273
Advanced Debugging Tools......Page 276
Introducing AJAX......Page 286
Using XMLHttpRequest......Page 290
Creating a Simple AJAX Library......Page 292
Creating an AJAX Quiz Using the Library......Page 293
Debugging AJAX Applications......Page 298
Introducing Greasemonkey......Page 306
Working with User Scripts......Page 309
Creating Your Own User Scripts......Page 312
Part V: Building Multimedia Applications with JavaScript......Page 324
Using Dynamic Images......Page 326
Creating Rollovers......Page 328
A Simple JavaScript Slideshow......Page 332
Introducing Plug-Ins......Page 342
JavaScript and Flash......Page 345
Playing Sounds with JavaScript......Page 346
Testing Sounds in JavaScript......Page 349
Part VI: Creating Complex Scripts......Page 356
Designing Drop-Down Menus......Page 358
Scripting Drop-Down Menu Behavior......Page 363
About the Game......Page 372
Creating the HTML Document......Page 374
Creating the Script......Page 376
Adding Style with CSS......Page 381
Creating a Scrolling Window......Page 390
Style Sheet Switching with JavaScript......Page 393
Learning Advanced JavaScript Techniques......Page 406
Future Web Technologies......Page 407
Planning for the Future......Page 410
Moving on to Other Languages......Page 411
Part VII: Appendixes......Page 420
JavaScript Websites......Page 422
This Book’s Website......Page 423
HTML and Text Editors......Page 424
Debugging Tools......Page 426
D......Page 428
I......Page 429
S......Page 430
X......Page 431
Built-in Objects......Page 432
Creating and Customizing Objects......Page 436
JavaScript Statements......Page 437
JavaScript Built-in Functions......Page 439
DOM Level 0......Page 440
DOM Level 1......Page 442
B......Page 446
C......Page 447
D......Page 448
F......Page 449
H......Page 450
M......Page 451
P......Page 452
S......Page 453
T......Page 454
X–Z......Page 455

Polecaj historie