| |
| |
Preface | |
| |
| |
Acknowledgments | |
| |
| |
| |
Getting Started | |
| |
| |
| |
Introducing the JavaScript Language | |
| |
| |
The JavaScript Language | |
| |
| |
JavaScript-Enabled Browsers | |
| |
| |
Client-Side JavaScript | |
| |
| |
Server-Side JavaScript | |
| |
| |
The Internet | |
| |
| |
Network Protocols | |
| |
| |
IP Addresses | |
| |
| |
Domains | |
| |
| |
The World Wide Web | |
| |
| |
How the World Wide Web Works | |
| |
| |
Helper Applications | |
| |
| |
Plug-ins | |
| |
| |
Java Applets | |
| |
| |
Summary of New Terms and Concepts | |
| |
| |
| |
Introducing the Scripting Environment | |
| |
| |
Hello World Tradition | |
| |
| |
Scripting Terminology | |
| |
| |
Understanding the Elements of the Hello World Script | |
| |
| |
JavaScript and HTML | |
| |
| |
Embedding a Script | |
| |
| |
Adding Text for Non-JavaScript Browsers | |
| |
| |
Loading a Script File | |
| |
| |
Adding JavaScript Comments | |
| |
| |
Adding HTML Comments | |
| |
| |
Displaying Text | |
| |
| |
Using the Basic Template | |
| |
| |
Immediate Activation Template | |
| |
| |
Deferred Activation | |
| |
| |
Recommended Programming Style Guide | |
| |
| |
General Comments and Rules | |
| |
| |
Comments | |
| |
| |
Code Indentation | |
| |
| |
White Space | |
| |
| |
Statements | |
| |
| |
Comparisons | |
| |
| |
Identifier Style (Variable, function, and object name choices) | |
| |
| |
Variables | |
| |
| |
Functions | |
| |
| |
Objects | |
| |
| |
Source Files (.js Files to be Included in a Script) | |
| |
| |
Looking at the Script-Writing Process | |
| |
| |
Creating the Hello World Script | |
| |
| |
Running the Hello World Script | |
| |
| |
Summary of New Terms and Concepts | |
| |
| |
| |
Introducing General Scripting Concepts | |
| |
| |
Data Types | |
| |
| |
Variables | |
| |
| |
Identifiers | |
| |
| |
White Space | |
| |
| |
Literal Values | |
| |
| |
Declaring a Variable | |
| |
| |
Assigning a Value to a Variable | |
| |
| |
Initializing a Variable | |
| |
| |
Functions | |
| |
| |
Operators | |
| |
| |
Precedence | |
| |
| |
Mathematical Operators | |
| |
| |
Expressions | |
| |
| |
Statements | |
| |
| |
Summary of New Terms and Concepts | |
| |
| |
| |
Debugging Scripts | |
| |
| |
Syntax Errors | |
| |
| |
Design or Logic Errors | |
| |
| |
HTML Layout and Script Parsing Order | |
| |
| |
Operator Precedence | |
| |
| |
JavaScript Error Messages | |
| |
| |
Function does not always return a value | |
| |
| |
identifier is a reserved word | |
| |
| |
missing ) after argument list | |
| |
| |
missing } after function body | |
| |
| |
missing ; after for-loop condition | |
| |
| |
missing ; after for-loop initializer | |
| |
| |
nested comment | |
| |
| |
out of memory | |
| |
| |
something cannot be indexed as an array | |
| |
| |
something has no properties | |
| |
| |
something is not defined | |
| |
| |
something is not a function | |
| |
| |
something is not a numeric literal | |
| |
| |
syntax error | |
| |
| |
unterminated string literal | |
| |
| |
Some Debugging Tips and Tricks | |
| |
| |
Using Netscape JavaScript Protocol to Debug Statements | |
| |
| |
Using Alerts to Set Breakpoints | |
| |
| |
String Formatting Tip | |
| |
| |
Looking at Object Properties | |
| |
| |
Debugging Checklist | |
| |
| |
Summary of New Terms and Concepts | |
| |
| |
| |
Creating HTML Pages | |
| |
| |
| |
Introducing Objects | |
| |
| |
Object Properties | |
| |
| |
Object Methods | |
| |
| |
Referencing Object Properties and Methods | |
| |
| |
Events | |
| |
| |
Object-Manipulation Statements | |
| |
| |
The this Keyword | |
| |
| |
The for...in Statement | |
| |
| |
The with Statement | |
| |
| |
The new Statement | |
| |
| |
Built-in Objects | |
| |
| |
Summary of New Terms and Concepts | |
| |
| |
| |
Creating Windows | |
| |
| |
Displaying a Status Message | |
| |
| |
Example of status and defaultStatus Properties | |
| |
| |
Explanation of Example Script | |
| |
| |
Example of status and defaultStatus Properties with a Timeout | |
| |
| |
Controlling the Structure of a Window | |
| |
| |
The frames Property | |
| |
| |
The length Property | |
| |
| |
Referring to a Window | |
| |
| |
Examples of frame and Window Naming Properties | |
| |
| |
Explanation of Example Scripts | |
| |
| |
A Three-Frame Window Example | |
| |
| |
Referencing document, history, and location Objects in a Window | |
| |
| |
Example of Referencing document, history, and location Objects | |
| |
| |
Opening a New Window | |
| |
| |
Examples of open() Method | |
| |
| |
Finding Which Window Is the Opener | |
| |
| |
Example of window.opener Property | |
| |
| |
Using the unescape() Function to Reformat Location Values | |
| |
| |
Determining the State of a Newly Opened Window | |
| |
| |
Example of Using the closed Property | |
| |
| |
Displaying Informational Messages in an Alert Window | |
| |
| |
Example of the alert( ) Method | |
| |
| |
Explanation of the windowAlert.html Script | |
| |
| |
Closing a Window | |
| |
| |
Example of the close() Method | |
| |
| |
Displaying a Confirmation Message | |
| |
| |
Example of confirm() Method | |
| |
| |
Prompting Users for Input | |
| |
| |
Example of prompt() Method | |
| |
| |
Controlling the Input Focus in Windows | |
| |
| |
Example of blur() and focus() Methods | |
| |
| |
Using Event Handlers to Control Window Focus | |
| |
| |
Example of onBlur and onFocus Event Handlers | |
| |
| |
Moving Around within a Window | |
| |
| |
Example of scroll() Method | |
| |
| |
Using Timeouts | |
| |
| |
Example of Timeouts in a Script | |
| |
| |
Using Event Handlers on Load and Unload | |
| |
| |
Example of onLoad and onUnload Event Handlers | |
| |
| |
Using an Event Handler to Capture Interpreter Error Messages | |
| |
| |
Example of Capturing and Displaying Error Messages | |
| |
| |
Explanation of windowOnerrorHandler.html Script | |
| |
| |
Example of Hiding Error Messages | |
| |
| |
Summary of New Terms and Concepts | |
| |
| |
| |
Creating Documents | |
| |
| |
Controlling Document Colors | |
| |
| |
Example of Setting Document Colors | |
| |
| |
Extracting Title, Location, Modification, and Document Referrer Information for a Document | |
| |
| |
Example of Displaying All of the Properties of a Document | |
| |
| |
Example of Comparison of location and URL Document Properties | |
| |
| |
Example of Finding Where a Document Came From | |
| |
| |
Working with the anchors Property | |
| |
| |
Example of Using a Named Anchor | |
| |
| |
Example of an Anchor That Is Also a Link | |
| |
| |
Example of a Link to Another Window | |
| |
| |
Example of Using Anchors to Move Around in a Document | |
| |
| |
Example of Using the Anchors Array | |
| |
| |
Working with the links Property | |
| |
| |
Example of Using the links Property | |
| |
| |
Referencing Forms in a Document | |
| |
| |
Example of Referencing Forms in a Document | |
| |
| |
Referencing Images in a Document | |
| |
| |
Example of Using the Images Array | |
| |
| |
Referencing Java Applets in a Document | |
| |
| |
Example of Including a Java Applet | |
| |
| |
Finding Plug-ins Embedded in a Document | |
| |
| |
Example of Counting Plug-Ins | |
| |
| |
Finding the Document Domain | |
| |
| |
Example of Finding the Document Domain | |
| |
| |
Storing User-Generated Information: the cookie Property | |
| |
| |
Limitations of the cookie Property | |
| |
| |
Example of Creating a cookie Property | |
| |
| |
Writing into a Document | |
| |
| |
Opening, Closing, and Clearing a Document | |
| |
| |
Example of Document Methods | |
| |
| |
Summary of New Terms and Concepts | |
| |
| |
| |
Controlling History | |
| |
| |
Displaying history Properties | |
| |
| |
Determining the Number of URL Links | |
| |
| |
Example of the history.length Property | |
| |
| |
Navigating the History List | |
| |
| |
Example of history.forward() and history.back() Methods | |
| |
| |
Example of Using Images with forward and back Methods | |
| |
| |
Example of history.go() Method | |
| |
| |
Data Tainting and History Properties | |
| |
| |
Example of current, previous, and next Properties | |
| |
| |
Extracting Information from the History List | |
| |
| |
Example of toString() Method | |
| |
| |
Summary of New Terms and Concepts | |
| |
| |
| |
Working with Images | |
| |
| |
Using the src Property | |
| |
| |
Example of Using image.src to Substitute Images | |
| |
| |
Prestaging Images with the lowsrc Property | |
| |
| |
Example of Prestaging Big Images with Low-Resolution Files | |
| |
| |
Checking If an Image Has Completed Loading | |
| |
| |
Example of Checking If an Image Has Completed Loading | |
| |
| |
Using Read-Only Image Properties | |
| |
| |
Example of Displaying Image Properties | |
| |
| |
Using the Image Constructor | |
| |
| |
Example of Using the Image Constructor | |
| |
| |
Example of Animation Script | |
| |
| |
Using the onLoad Event Handler | |
| |
| |
Using the onLoad Event Handler to Display an Alert | |
| |
| |
Using the onLoad Event Handler to Create a Slide Show | |
| |
| |
Using the onLoad Event Handler to Change the Image Source | |
| |
| |
Getting into Trouble with the onLoad Event Handler | |
| |
| |
Planning for Error Handling | |
| |
| |
Using the onError Event Handler to Catch Errors | |
| |
| |
Planning for the Stopping of Image Loading | |
| |
| |
Using the onAbort Event Handler When Users Click on the Stop Button | |
| |
| |
| |
Embedding Java Applets in Your Web Page | |
| |
| |
Applet Files | |
| |
| |
Downloading the JDK | |
| |
| |
Running the Java Compiler | |
| |
| |
Run | |