: Christian Heilmann
: Beginning JavaScript with DOM Scripting and Ajax From Novice to Professional
: Apress
: 9781430201847
: 1
: CHF 32.20
:
: Informatik
: English
: 512
: Wasserzeichen/DRM
: PC/MAC/eReader/Tablet
: PDF

This is the most up-to-date book on JavaScript available, covering current standards, techniques, and practices. It provides all you need to know to hit the ground running, without making you trawl through hundreds of pages of syntax. The book contains multiple chapters on Ajax and DOM Scripting, which are two of the hottest web development and design tools available today. Using a pragmatic and thorough approach, the book ensures that even the most novice JavaScript programmers will become familiar and comfortable using the tools presented.



Christian Heilmann grew up in Germany and, after a year working with people with disabilities through the Red Cross, he spent a year as a radio producer. Beginning in 1997, he worked for several agencies in Munich as a web developer. In 2000, he moved to the U.S. to work for eToys and, after the dot-com crash, he moved to the U.K., where he currently works as a lead developer for Agilisys. He publishes an almost-daily blog at http://wait-till-i.com and runs an article repository at http://icant.co.uk. He is a member of the Web Standards Project's DOM Scripting Task Force.
Contents6
Foreword12
About the Author13
About the Technical Reviewer14
Acknowledgments15
Introduction16
Chapter 1 Getting Started with JavaScript19
The Why of JavaScript21
What Is JavaScript?22
Problems and Merits of JavaScript23
Why Use JavaScript If It Cannot Be Relied On?24
JavaScript in a Web Page and Essential Syntax25
JavaScript Syntax26
Code Execution27
An Aside About Functions29
Objects30
Simple JavaScript Example31
Summary34
Chapter 2 Data and Decisions35
Data, Data Types, and Data Operators36
The String Data Type36
Operators39
JavaScript Variables41
Converting Different Types of Data44
The Composite Data Types: Array and Object48
Objects JavaScript Supplies You with: String, Date, and Math48
Arrays57
The Array Object s Methods and Properties60
Making Decisions in JavaScript63
The Logical and Comparison Operators63
Conditional Statements67
Testing Multiple Values: the switch Statement70
Repeating Things: Loops72
Summary77
Chapter 3 From DHTML to DOM Scripting78
JavaScript As the Behavior Layer 80
Object Detection vs. Browser Dependence82
Progressive Enhancement85
JavaScript and Accessibility86
Good Coding Practices88
Naming Conventions88
Code Layout89
Commenting91
Functions93
Short Code via Ternary Operator96
Sorting and Reuse of Functions97
Variable and Function Scope97
Keeping Scripts Safe with the Object Literal98
Summary100
Chapter 4 HTML and JavaScript102
The Anatomy of an HTML Document102
Providing Feedback in Web Pages via JavaScript: The Old School Ways106
Using window Methods: prompt(), alert(), and confirm()107
Accessing the Document via the DOM113
Of Children, Parents, Siblings, and Values116
From the Parents to the Children117
From the Children to the Parents119
Among Siblings120
Changing Attributes of Elements124
Creating, Removing, and Replacing Elements126
Avoiding NOSCRIPT130
Shortening Your Scripts via InnerHTML132
DOM Summary: Your Cheat Sheet133
DOMhelp: Our Own Helper Library135
Summary139
Chapter 5 Presentation and Behavior (CSS and Event Handling)140
Changing the Presentation Layer via JavaScript140
Helping the CSS Designer148
Changing the Document s Behavior via Event Handling170
Events in the W3C-Compliant World173
Fixing Events for the Non-W3C-Compliant World182
Never Stop Optimizing189
The Ugly Page Load Problem and Its Ugly Solutions190
Reading and Filtering Keyboard Entries191
The Dangers of Event Handling196
Summary197
Chapter 6 Common Uses of JavaScript: Images and Windows199
Images and JavaScript199
Basics of Image Scripting200
Preloading Images202
Rollover Effects203
Slide Shows212
Summary of Images and JavaScript227
Windows and JavaScript228
Window Properties229
Window Methods231
Summary: Windows and JavaScript254
Summary255
Chapter 7 JavaScript and User Interaction: Navigation and Forms256
Navigation and JavaScript256
The Fear of the Page Reload257
Basics of Navigation and JavaScript257
Browser Navigation260
In-Page Navigation261
Site Navigation270
Pagination278
Summary of Navigation with JavaScript287
Forms and JavaScript287
Basics of Forms with JavaScript289
Form Elements290
Interactive Forms: Hiding and Showing Dependent Elements306
Custom Form Elements312
Summary of Forms and JavaScript312
Summary312
Chapter 8 Back-End Interaction with Ajax314
Household Cleaning Liquid, Football Club, or Flash Gordon s Spacecraft: What Is Ajax?315
Et Tu, Cache?324
Putting the X Back into Ajax324
Replacing XML with JSON329
Using Server-Side Scripts to Reach Third-Party Content331
XHR on Slow Connections335
A Larger Ajax Example: Connected Select Boxes338
Optional Dynamic Ajax Menus346
Summary355
Chapter 9 Data Validation Techniques357
Pros and Cons of Client-Side JavaScript Validation357
A Quick Reminder About Protecting Content with JavaScript358
The One-Size-Fits-All Validation Myth359
Basic JavaScript Validation with String and Numeric Methods360
String Validation Methods360
Numeric Validation Methods366
Regular Expressions371
Syntax and Attributes371
Wildcard Searches, Constraining Scope,