Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Cover Page
JavaScript: The Complete Reference, Third Edition
Copyright Page
Contents at a Glance
Contents
Acknowledgments
Introduction
Part I Introduction
Chapter 1 Introduction to JavaScript
Hello JavaScript World
Hello Errors
Adding JavaScript to XHTML Documents
The <script> Element
Event Handlers
Linked Scripts
JavaScript Pseudo-URL
JavaScript Usage Considerations
Script Masking
The <noscript> Element
Language Versions
Cross-Browser Concerns
Living with Other Scripts
JavaScript: A Real Programming Language
History of JavaScript
Common Uses of JavaScript
The Rise of JavaScript Libraries
The Future of JavaScript
Summary
Chapter 2 Overview of JavaScript Core Language Features
Basic Definitions
Execution Order
Case Sensitivity
HTML and Case Sensitivity
Whitespace
Statements
Semicolons
Blocks
Variables
Basic Data Types
Weak Typing
Type Conversion
Composite Types
Objects
Arrays
Functions as Data Types
Regular Expression Literals and Object
Expressions
Arithmetic Operators
Assignment Operators
Logical Operators
Conditional Operator
Type Operators
Comma Operator
Relational Operators
Operator Precedence and Associativity
Flow Control
Loops
Loop Control
Input and Output in JavaScript
Functions
Scoping Rules
Regular Expressions
Exceptions
Comments
ECMAScript 5 Changes
“use strict”;
Native JSON Support
Function.prototype.bind( )
ISO Dates
Native Array Additions
String.prototype.trim( )
Object/Property Additions
Emerging Features
Summary
Part II Core Language
Chapter 3 Data Types and Variables
Key Concepts
Weak Typing
JavaScript’s Primitive Types
Numbers
Strings
Booleans
Undefined and Null
Composite Types
Objects
Arrays
Functions
The typeof Operator
Type Conversion
Conversion Rules for Primitive Types
Promotion of Primitive Data to Objects
Explicit Type Conversion
Variables
Identifiers
Variable Declaration
Implicit Variable Declaration
Variable Scope
Constants
Summary
Chapter 4 Operators, Expressions, and Statements
Statement Basics
Whitespace
Termination: Semicolons and Returns
Blocks
Operators
Assignment Operator
Arithmetic Operators
Bitwise Operators
Bitwise Shift Operators
Combining Arithmetic and Bitwise Operations with Assignment
Increment and Decrement
Comparison Operators
Logical Operators
? Operator
Comma Operator
void Operator
typeof
Object Operators
Operator Precedence and Associativity
Core JavaScript Statements
if Statements
switch
while Loops
do-while Loops
for Loops
Loop Control with continue and break
Object-Related Statements
Other Statements
Summary
Chapter 5 Functions
Function Basics
Parameter Passing Basics
Return Statements
Parameter Passing: In and Out
Global and Local Variables
Variable Naming for Scope
Inner Functions
Closures
Functions as Objects
Function Literals
Static Variables
Advanced Parameter Passing
Advanced Function Properties and Methods
Recursive Functions
Summary
Chapter 6 Objects
Objects in JavaScript
Object Fundamentals
Object Creation
Object Destruction and Garbage Collection
Properties
Objects Are Reference Types
Common Properties and Methods
Object-Oriented JavaScript
Prototype-Based Objects
Constructors
Prototypes
Class Properties
Inheritance via the Prototype Chain
Overriding Default Methods and Properties
ECMAScript 5 Object-Related Changes
JavaScript’s Object-Oriented Reality
Summary
Chapter 7 Array, Date, Math, and Type-Related Objects
Array
Accessing Array Elements
Adding and Changing Array Elements
Removing Array Elements
The length Property
Arrays as Stacks and Queues
Manipulating Arrays
Multidimensional Arrays
Extending Arrays with Prototypes
ECMAScript 5 Array Additions
Boolean
Date
Creating Dates
Manipulating Dates
ECMAScript 5 Date Additions
Global
Math
Random Numbers
Number
String
Examining Strings
Manipulating Strings
Marking Up Strings as Traditional HTML
ECMAScript 5 String Changes
Summary
Chapter 8 Regular Expressions
The Need for Regular Expressions
Introduction to JavaScript Regular Expressions
Creating Patterns
RegExp Object
test( )
Subexpressions
compile( )
exec( )
RegExp Properties
String Methods for Regular Expressions
search( )
split( )
replace( )
match( )
Advanced Regular Expressions
Multiline Matching
Noncapturing Parentheses
Lookahead
Greedy Matching
Limitations of Regular Expressions
Summary
Chapter 9 JavaScript Object Models
Object Model Overview
The Initial JavaScript Object Model
The Document Object
Accessing Document Elements by Position
Accessing Document Elements by Name
Simple Event Handling
Setting Event Handlers Inline
Direct Assignment of Event Handlers
Setting Event Listeners
Invoking Event Handlers
JavaScript + DOM + Selection + Events = Program
The Evolution of the JavaScript Object Model
The Early Evolution of Browser Object Models
DHTML-Oriented Object Models
Internet Explorer 4’s DHTML Object Model
Beyond the DHTML Object Models
Summary
Chapter 10 The Standard Document Object Model
DOM Flavors
What Browsers Say Is Implemented
Document Trees
Basic Element Access: getElementById( )
Tree Traversal Basics
Other Element Access Methods
getElementsByName( )
Common JavaScript Collections
getElementsByTagName( )
Common Tree Traversal Starting Points
document.getElementsByClassName( )
querySelector( ) and querySelectorAll( )
Creating Nodes
Appending and Inserting Nodes
Text Nodes and normalize( ) Method
insertBefore( ) method
Other Insertion Methods
Dynamic Markup Insertion Realities
innerHTML
outerHTML
innerText and outerText
insertAdjacentHTML( ) and insertAdjacentText( )
document.write( ) and document.writeln( )
Copying Nodes
Deleting and Replacing Nodes
Modifying Text Nodes
Manipulating Attributes
Attribute Nodes
Other Node Methods
Namespaces
The DOM and HTML Elements
HTML Element Mappings
DOM Table Manipulation
The DOM and Css
Inline Style Manipulation
Dynamic Style Using Classes and Collections
Computed Style
Accessing Complex Style Rules
DOM Traversal API
DOM Range Selections
Continued DOM Evolution
Summary
Chapter 11 Event Handling
Overview of Events and Event Handling
The Traditional Event Model
Event Binding with HTML Attributes
Binding Event Handler Attributes with JavaScript
Event Handler Scope Details
Return Values
Firing Events Manually
Overview of Modern Event Models
Internet Explorer’s Proprietary Model
attachEvent( ) and detachEvent( )
Event Object
Event Bubbling
Simulating Event Routing
Event Creation
DOM Event Model
Traditional Binding Changes
addEventListener( ) and removeEventListener( )
Event Object
Preventing Default Actions
Controlling Event Propagation
Event Creation
Event Types
Mouse Events
Ui Events
Focus Events
Keyboard Events
Text Events
Mutation Events
Nonstandard Events
Custom Events
Browser State and Loading Events
Event Model Issues
Summary
Part III Applied JavaScript
Chapter 12 Windows, Frames, and Overlays
Introduction to the Window Object
Dialogs
alert( )
confirm( )
prompt( )
Emerging and Proprietary Dialog Methods
showModalDialog( )
showModelessDialog( )
createPopup( )
Opening and Closing Generic Windows
Window Features
Detecting and Controlling Window Chrome
Practicalities of Spawned Windows
Building Window Contents
Overlays Instead of Windows
Controlling Windows
focus( ) and blur( )
stop( )
print( )
find( )
Moving Windows
Resizing Windows
Scrolling Windows
Accessing and Setting a Window’s Location
Hash Values in URLs
Manipulating a Window’s History
pushstate( ) and replacestate( )
Trying to Control the Window’s Status Bar
Setting Window Timeouts and Intervals
Window Events
Interwindow Communication Basics
Interwindow Message Passing with postMessage( )
Frames: A Special Case of Windows
Inline Frames
Applied Frames
Summary
Chapter 13 Form Handling
The Need for JavaScript Form Checking
Form Basics
Accessing Forms and Fields
Form Fields
Common Input Element Properties
Buttons
Traditional Text Fields
HTML5 Semantic Text Fields
Text Areas
Checkboxes and Radio Buttons
Select Menus
Date Pickers
Color
Sliders
File Upload Fields
Hidden Fields
Other Form Features: Label, Fieldset, Output, and Legend
Form Usability and JavaScript
First Field Focus
Labels and Field Selection
Advisory and Status Messages
Data Lists
Disabled and Read-Only Fields
Form Validation
Abstracting Form Validation
Error Messages
onchange Handlers
Keyboard Masking
HTML5 Validation Improvements
Validation Attributes
Validation Properties and Methods
novalidate Attribute
Miscellaneous Html5 Form Changes
Internationalization
Summary
Chapter 14 User Interface Elements
Adding JavaScript
Exploring Progressive Enhancement
Graceful Degradation Approaches
HTML5 Support for Rich Interaction
Menus and Context Menus
Drag-and-Drop Functionality
Content Editing
Revealing Content on Demand
User Feedback
Summary
Chapter 15 Ajax and Remote JavaScript
Ajax Defined
Hello Ajax World
XML HttpRequest Object
XHR Instantiation and Cross-Browser Concerns
ActiveX XHR Fallback Details
A Cross-Browser XHR Wrapper
XHR Request Basics
Synchronous Requests
Asynchronous Requests
Sending Data via GET
Sending Data via Post
Using Other HTTP Methods
Setting Request Headers
Response Basics
readyState Explored
status and statusText
responseText
responseXML
response and responseType
JSON
Script Responses
Response Headers
Controlling Requests
Authentication with XHRs
Propriety and Emerging XHR Features
Managing MIME Types
Multipart Responses
onload, onloadstart, and onloadend
onprogress and Partial Responses
onerror
Form Serialization
File Uploads with iframes
Cross-Domain Ajax Requests
Internet Explorer’s XDRs
Non-XHR Communication Methods
Image Tag
Script Tag
Comet and Sockets
Polling: Fast or Long
The Long Slow Load
WebSockets
Ajax Implications and Challenges
Summary
Chapter 16 Browser Management
Browser Detection Basics
The Navigator Object
What to Detect
Technology Detection
Visual Detection: Screen Object
User Characteristics
Network State and Performance
Simple Page Load Metrics
window.performance.timing
Browser Control
Simulating Browser Button Presses
State Management
Cookies in JavaScript
Using Cookies for User State Management
Cookie Limitations
Storage
IndexedDB
AppCache
Script Execution
Web Workers
Summary
Chapter 17 Media Management
Image Handling
Applied Images
DHTML, DOMEffects, and Animation
Client-Side Bitmap Graphics with <canvas>
Drawing and Styling Lines and Shapes
Drawing Arcs and Curves
Scaling, Rotating, and Translating Drawings
Using Bitmaps in Drawings
Text Support for <canvas>
Compositing
Saving State
<canvas> Considerations
Client-Side Vector Graphics with SVG
Including SVG
Drawing with SVG
SVG Interaction and Animation
HTML5 Media Handling
<video>
<audio>
Media Events
Plug-Ins
Embedding Content for Plug-Ins
MIME Types
Detecting Specific Plug-Ins
Interacting with Plug-Ins
ActiveX
Including ActiveX Controls
Interacting with ActiveX Controls
Java Applets
Including Applets
Java Detection
Accessing Applets in JavaScript
Accessing JavaScript with Applets
The Uncertain Future
Summary
Chapter 18 Trends and Practices
Writing Quality JavaScript
Coding Style
Comments and Documentation
Understanding Errors
Debugging
Defensive Programming
Utilizing Frameworks and Libraries
Security
JavaScript Protection
JavaScript’s Security Policy
Same-Origin Policy
Trusted External Scripts
Cross-Site Scripting
Cross-Site Request Forgery (CSRF)
Performance
Performance Measurements and Tools
Page-Load Performance
Runtime Performance
Trends
JavaScript Everywhere
“Fixing” and Hiding JavaScript
Accepting JavaScript
Summary
Appendix JavaScript Reserved Words
Reserved Quirks
Index
← Prev
Back
Next →
← Prev
Back
Next →