Synopses & Reviews
This Fifth Edition is completely revised and expanded to cover JavaScript as it is used in today's Web 2.0 applications. This book is both an example-driven programmer's guide and a keep-on-your-desk reference, with new chapters that explain everything you need to know to get the most out of JavaScript, including:
- Scripted HTTP and Ajax
- XML processing
- Client-side graphics using the canvas tag
- Namespaces in JavaScript--essential when writing complex programs
- Classes, closures, persistence, Flash, and JavaScript embedded in Java applications
Part I explains the core JavaScript language in detail. If you are new to JavaScript, it will teach you the language. If you are already a JavaScript programmer, Part I will sharpen your skills and deepen your understanding of the language.
Part II explains the scripting environment provided by web browsers, with a focus on DOM scripting with unobtrusive JavaScript. The broad and deep coverage of client-side JavaScript is illustrated with many sophisticated examples that demonstrate how to:
- Generate a table of contents for an HTML document
- Display DHTML animations
- Automate form validation
- Draw dynamic pie charts
- Make HTML elements draggable
- Define keyboard shortcuts for web applications
- Create Ajax-enabled tool tips
- Use XPath and XSLT on XML documents loaded with Ajax
- And much more
Part III is a complete reference for core JavaScript. It documents every class, object, constructor, method, function, property, and constant defined by JavaScript 1.5 and ECMAScript Version 3.
Part IV is a reference for client-side JavaScript, covering legacy web browser APIs, the standard Level 2 DOM API, and emerging standards such as the XMLHttpRequest object and the canvas tag.
More than 300,000 JavaScript programmers around the world have madethis their indispensable reference book for building JavaScript applications.
"A must-have reference for expert JavaScript programmers...well-organized and detailed."
-- Brendan Eich, creator of JavaScript
Synopsis
Part tutorial and part reference, this book not only helps you develop new JavaScript skills by building on your basic understanding of HTML, CSS, and the Web in general, it also serves as a detailed reference for the more experienced web developers among you. Furthermore, the fifth edition now includes advanced material on the latest developer topics, such as scripting Flash with JavaScript, HTTP and Ajax, DOM, SVG, XML, web services, and remote scripting. Like all O'Reilly Definitive Guides, this book provides the most comprehensive reference section on the market, documenting every object, property, method, event handler, function and constructor used by client-side JavaScript. The new edition has also been revamped to cover the latest browsers, language updates, extensions, and JavaScript standards. No wonder it's the top-selling JavaScript book of all time. No other book comes close.
Synopsis
Part tutorial and part reference, this book not only helps you develop new JavaScript skills by building on users' basic understanding of HTML, CSS, and the Web in general, it also serves as a detailed reference for the more experienced Web developer.
About the Author
David Flanagan is a computer programmer who spends most of his time writing about JavaScript and Java. His books with O'Reilly include Java in a Nutshell, Java Examples in a Nutshell, Java Foundation Classes in a Nutshell, JavaScript: The Definitive Guide, and JavaScript Pocket Reference. David has a degree in computer science and engineering from the Massachusetts Institute of Technology. He lives with his wife and children in the U.S. Pacific Northwest bewteen the cities of Seattle, Washington and Vancouver, British Columbia. David has a blog at www.davidflanagan.com.
Table of Contents
Dedication; Preface; What's New in the Fifth Edition; Using This Book; Conventions Used in This Book; Using Code Examples; Safari® Enabled; How to Contact Us; Acknowledgments; Chapter 1: Introduction to JavaScript; 1.1 What Is JavaScript?; 1.2 Versions of JavaScript; 1.3 Client-Side JavaScript; 1.4 JavaScript in Other Contexts; 1.5 Exploring JavaScript; Part I: Core JavaScript; Chapter 2: Lexical Structure; 2.1 Character Set; 2.2 Case Sensitivity; 2.3 Whitespace and Line Breaks; 2.4 Optional Semicolons; 2.5 Comments; 2.6 Literals; 2.7 Identifiers; 2.8 Reserved Words; Chapter 3: Datatypes and Values; 3.1 Numbers; 3.2 Strings; 3.3 Boolean Values; 3.4 Functions; 3.5 Objects; 3.6 Arrays; 3.7 null; 3.8 undefined; 3.9 The Date Object; 3.10 Regular Expressions; 3.11 Error Objects; 3.12 Type Conversion Summary; 3.13 Primitive Datatype Wrapper Objects; 3.14 Object-to-Primitive Conversion; 3.15 By Value Versus by Reference; Chapter 4: Variables; 4.1 Variable Typing; 4.2 Variable Declaration; 4.3 Variable Scope; 4.4 Primitive Types and Reference Types; 4.5 Garbage Collection; 4.6 Variables as Properties; 4.7 Variable Scope Revisited; Chapter 5: Expressions and Operators; 5.1 Expressions; 5.2 Operator Overview; 5.3 Arithmetic Operators; 5.4 Equality Operators; 5.5 Relational Operators; 5.6 String Operators; 5.7 Logical Operators; 5.8 Bitwise Operators; 5.9 Assignment Operators; 5.10 Miscellaneous Operators; Chapter 6: Statements; 6.1 Expression Statements; 6.2 Compound Statements; 6.3 if; 6.4 else if; 6.5 switch; 6.6 while; 6.7 do/while; 6.8 for; 6.9 for/in; 6.10 Labels; 6.11 break; 6.12 continue; 6.13 var; 6.14 function; 6.15 return; 6.16 throw; 6.17 try/catch/finally; 6.18 with; 6.19 The Empty Statement; 6.20 Summary of JavaScript Statements; Chapter 7: Objects and Arrays; 7.1 Creating Objects; 7.2 Object Properties; 7.3 Objects as Associative Arrays; 7.4 Universal Object Properties and Methods; 7.5 Arrays; 7.6 Reading and Writing Array Elements; 7.7 Array Methods; 7.8 Array-Like Objects; Chapter 8: Functions; 8.1 Defining and Invoking Functions; 8.2 Function Arguments; 8.3 Functions as Data; 8.4 Functions as Methods; 8.5 Constructor Functions; 8.6 Function Properties and Methods; 8.7 Utility Function Examples; 8.8 Function Scope and Closures; 8.9 The Function() Constructor; Chapter 9: Classes, Constructors, and Prototypes; 9.1 Constructors; 9.2 Prototypes and Inheritance; 9.3 Simulating Classes in JavaScript; 9.4 Common Object Methods; 9.5 Superclasses and Subclasses; 9.6 Extending Without Inheriting; 9.7 Determining Object Type; 9.8 Example: A defineClass( ) Utility Method; Chapter 10: Modules and Namespaces; 10.1 Creating Modules and Namespaces; 10.2 Importing Symbols from Namespaces; 10.3 Module Utilities; Chapter 11: Pattern Matching with Regular Expressions; 11.1 Defining Regular Expressions; 11.2 String Methods for Pattern Matching; 11.3 The RegExp Object; Chapter 12: Scripting Java; 12.1 Embedding JavaScript; 12.2 Scripting Java; Part II: Client-Side JavaScript; Chapter 13: JavaScript in Web Browsers; 13.1 The Web Browser Environment; 13.2 Embedding Scripts in HTML; 13.3 Event Handlers in HTML; 13.4 JavaScript in URLs; 13.5 Execution of JavaScript Programs; 13.6 Client-Side Compatibility; 13.7 Accessibility; 13.8 JavaScript Security; 13.9 Other Web-Related JavaScript Embeddings; Chapter 14: Scripting Browser Windows; 14.1 Timers; 14.2 Browser Location and History; 14.3 Obtaining Window, Screen, and Browser Information; 14.4 Opening and Manipulating Windows; 14.5 Simple Dialog Boxes; 14.6 Scripting the Status Line; 14.7 Error Handling; 14.8 Multiple Windows and Frames; 14.9 Example: A Navigation Bar in a Frame; Chapter 15: Scripting Documents; 15.1 Dynamic Document Content; 15.2 Document Properties; 15.3 Legacy DOM: Document Object Collections; 15.4 Overview of the W3C DOM; 15.5 Traversing a Document; 15.6 Finding Elements in a Document; 15.7 Modifying a Document; 15.8 Adding Content to a Document; 15.9 Example: A Dynamically Created Table of Contents; 15.10 Querying Selected Text; 15.11 The IE 4 DOM; Chapter 16: Cascading Style Sheets and Dynamic HTML; 16.1 Overview of CSS; 16.2 CSS for DHTML; 16.3 Scripting Inline Styles; 16.4 Scripting Computed Styles; 16.5 Scripting CSS Classes; 16.6 Scripting Stylesheets; Chapter 17: Events and Event Handling; 17.1 Basic Event Handling; 17.2 Advanced Event Handling with DOM Level 2; 17.3 The Internet Explorer Event Model; 17.4 Mouse Events; 17.5 Key Events; 17.6 The onload Event; 17.7 Synthetic Events; Chapter 18: Forms and Form Elements; 18.1 The Form Object; 18.2 Defining Form Elements; 18.3 Scripting Form Elements; 18.4 Form Verification Example; Chapter 19: Cookies and Client-Side Persistence; 19.1 An Overview of Cookies; 19.2 Storing Cookies; 19.3 Reading Cookies; 19.4 Cookie Example; 19.5 Cookie Alternatives; 19.6 Persistent Data and Security; Chapter 20: Scripting HTTP; 20.1 Using XMLHttpRequest; 20.2 XMLHttpRequest Examples and Utilities; 20.3 Ajax and Dynamic Scripting; 20.4 Scripting HTTP with