Home Page Icon
Home Page
Table of Contents for
IV. AJAX and Beyond
Close
IV. AJAX and Beyond
by Steve Suehring
JavaScript Step by Step
JavaScript Step by Step
Dedication
SPECIAL OFFER: Upgrade this ebook with O’Reilly
A Note Regarding Supplemental Files
Acknowledgments
Introducing JavaScript Step by Step
Features and Conventions of This Book
Using the Book's CD
What's on the CD?
Minimum System Requirements
Using the Sample Files
Getting Help
Getting Help with This Book and Its CD
I. JavaWhat? The Where, Why, and How of JavaScript
1. JavaScript Is More Than You Might Think
A Brief History of JavaScript
Enter Internet Explorer 3
And Then Came ECMAScript
So Many Standards…
The DOM
What's in a JavaScript Program?
Placing JavaScript on Your Web Page
What JavaScript Can Do
What JavaScript Can't Do
JavaScript Can't Be Forced on a Client
JavaScript Can't Guarantee Data Security
JavaScript Can't Cross Domains
JavaScript Doesn't Do Servers
Tips for Using JavaScript
Where JavaScript Fits
Which Browsers Should the Site Support?
Exercises
2. Developing in JavaScript
JavaScript Development Options
Configuring Your Environment
Writing in JavaScript with Visual Studio 2005
Your First Web (and JavaScript!) Project with Visual Studio 2005
Using External JavaScript Files with Visual Studio 2005
Writing JavaScript with Eclipse
Your First Web (and JavaScript!) Project with Eclipse
Using External JavaScript Files with Eclipse
Writing JavaScript Without an IDE
Your First Web (and JavaScript) Project with Notepad
Using External JavaScript Files Without an IDE
Debugging JavaScript
Exercises
3. JavaScript Syntax and Statements
A Bit of Housekeeping
Case Sensitivity
White Space
Comments
Semicolons
Line Breaks
Placing JavaScript Correctly
JavaScript Statements
What's in a Statement?
The Two Types of JavaScript Statements
Reserved Words in JavaScript
A Quick Look at Functions
Exercises
4. Working with Variables and Data
Data Types in JavaScript
Numbers
Numeric Functions
The Math Object
Strings
Escaping Quotes
Other Escape Characters
String Methods and Properties
Booleans
Null
Undefined
Objects
Arrays
Defining and Using Variables
Declaring Variables
Variable Types
Variable Scope
References and Garbage Collection
Type Conversions
Number Conversions
String Conversions
Boolean Conversions
Exercises
5. Using Operators and Expressions
Meet the Operators
Additive Operators
Multiplicative Operators
Bitwise Operators
Equality Operators
Relational Operators
The in Operator
The instanceof Operator
Unary Operators
Incrementing and Decrementing
Converting to a Number with the Plus Sign
Creating a Negative Number with the Minus Sign
Bitwise Not and Logical Not
The delete Operator
The typeof Operator
The void Operator
Assignment Operators
Exercises
II. Applying JavaScript
6. Controlling Flow with Conditionals and Loops
If (and how)
Syntax for if Statements
The prompt() Function in Windows Internet Explorer 7
Compound Conditions
Nested Conditions
Else if and else Statements
Multiple Levels of Conditionals
Ternary Conditionals
Switch
Looping with while
The while Statement
Making Sure the Code Executes At Least Once
Changing the Condition
The do…while Statement
Using for Loops
The for Loop
The for…in Loop
The for each…in Loop
Validating Forms with Conditionals
Exercises
7. Working with Functions
What's in a Function?
Function Arguments
Variable Scoping Revisited
Return Values
More on Calling Functions
Unnamed Functions (Function Literals)
Methods
A Look at Dialog Functions
Exercises
8. Objects in JavaScript
Object-Oriented Development
Objects
Properties
Methods
Classes
Creating Objects
Adding Properties to Methods
Displaying Object Properties
Looking for a Property
Adding Methods to Objects
More About Arrays
The length Property
Array Methods
Adding and Removing Elements
Built-in Objects
The Date Object
Exercises
9. The Browser Object Model
Introducing the Browser
The Browser Hierarchy
Events
A Sense of Self
Getting Information About the Screen
Using the navigator Object
The location Object
The history Object
Exercises
10. The Document Object Model
The Document Object Model Defined
DOM Level 0: The Legacy DOM
DOM Levels 1 and 2
The DOM as a Tree
Working with Nodes
Retrieving Elements
Retrieving by ID
Retrieving by Tag Name
Working with Attributes
Viewing Attributes
Setting Attributes
Creating Elements
Adding Text
Adding an Element and Setting an ID
Deleting Elements
Exercises
III. Integrating JavaScript into Design
11. Using JavaScript with Web Forms
JavaScript and Web Forms
Obtaining Form Data
Working with Form Information
Working with Select Boxes
Working with Check Boxes
Working with Radio Buttons
Prevalidating Form Data
Hacking JavaScript Validation
Validating a Text Field
Exercises
12. Creating and Consuming Cookies
A Look at Cookies
Creating Cookies with JavaScript
A Simple Cookie
Setting a Cookie's Expiration Date
Setting the Cookie Path
Setting the Cookie Domain
Working with Secure Cookies
Reading Cookies with JavaScript
Removing Cookies
Exercises
13. Working with Images in JavaScript
Working with Image Rollovers
A Simple Rollover
The Better Way
Preloading Images
Working with Slideshows
Creating the Show
Moving Backward
Working with Image Maps
Exercises
14. Browsers and JavaScript
Understanding Window Events
The Event Models
Using the DOM 0 Model
Newer Event Models: W3C and Windows Internet Explorer
A Generic Event Handler
Detecting Things About the Visitor
A Brief Look at the userAgent Property
Feature Testing
Keeping JavaScript Away from Older Browsers
Other navigator Properties and Methods
Opening, Closing, and Resizing Windows
Window Open and Close: In Action
A Closer Look at the Main Form Page
A Closer Look at the New Window
Window Opening Best Practices
No JavaScript Necessary?
Resizing and Moving Windows
Timers
Exercises
15. JavaScript and CSS
What Is CSS?
Properties and Selectors
Applying CSS
The Relationship Between JavaScript and CSS
Setting Element Styles by ID
Setting Element Styles by Type
Retrieving Element Styles with JavaScript
Modifying Style Sheets with JavaScript
Exercises
16. JavaScript Error Handling
An Overview of Error Handling
Using try/catch
And Finally…
Using the onerror Event
Attaching onerror to the window Object
Ignoring Errors
Attaching onerror to the image Object
Exercises
IV. AJAX and Beyond
17. JavaScript and XML
Using XML with JavaScript
An Example XML Document
Loading an XML Document with JavaScript
Importing the Document
Displaying the Document
A Preview of Things to Come
Exercises
18. A Touch of AJAX
Introduction to AJAX
The XMLHttpRequest Object
Instantiating the XMLHttpRequest Object
Sending an AJAX Request
Processing an AJAX Response
Processing XML Responses
Working with JSON
Processing Headers
Using the POST Method
Case Study: Live Searching and Updating
Exercises
19. A Bit Deeper into AJAX
Creating an HTML Table with XML and CSS
Styling the Table with CSS
Creating a Dynamic Drop-down Box
Accepting Input from the User and AJAX
Exercises
A. Answer Key to Exercises
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16
Chapter 17
Chapter 18
Chapter 19
Index
About the Author
SPECIAL OFFER: Upgrade this ebook with O’Reilly
Copyright
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
16. JavaScript Error Handling
Next
Next Chapter
17. JavaScript and XML
Part IV. AJAX and Beyond
Chapter 17
Chapter 18
Chapter 19
Appendix A
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset