By David Flanagan
Copyright © 1996, 1997, 1998 O'Reilly & Associates
The lines below list the examples included in the third edition of the book JavaScript: The Definitive Guide. Click on the "View Source" link to see the source code for each one. Some of these examples are standalone programs, that you can run by clicking on the "Run Examples" link. Other examples are not standalone programs, and you cannot run them directly. You can, however, modify them to run on their own, or you can integrate them into larger programs.
These examples come with no warranty of any kind. They are copyrighted material and are not in the public domain. You may study, use, modify, and distribute them for any purpose, as long as you retain the copyright notice at the top of each file.
If you are viewing these examples online, we recommend that you download the full set of examples and install them locally on your computer. The examples are available for download in two formats:
Download the examples in ZIP format:
js3examples.zip
Download the examples in .tar.gz format:
js3examples.tar.gz
1-1: A Simple JavaScript Program | View source | Run Example |
1-2: An HTML Form with a JavaScript Event Handler Defined | View source | Run Example |
1-3: Computing Loan Payments with JavaScript | View source | Run Example |
7-1: Defining JavaScript Functions | View source | |
7-2: Using Functions as Data | View source | |
7-3: Function That Prints a Stack Trace | View source | |
7-4: Function to Verify Correct Number of Arguments | View source | |
8-1: A Rectangle Object Constructor Function | View source | |
8-2: Defining and Invoking a Method | View source | |
8-3: Defining Methods in a Constructor | View source | |
8-4: Defining a Circle Class with a Prototype Object | View source | |
8-5: Defining Circle Instance and Class Variables and Methods | View source | |
8-6: A Complex Number Class | View source | |
11-1: Copying, Passing, and Comparing by Value | View source | |
11-2: Copying, Passing, and Comparing by Reference | View source | |
11-3: References Themselves Are Passed by Value | View source | |
11-4: Are Strings Compared by Value or by Reference? | View source | |
11-5: An instanceOf() Method Using __proto__ | View source | |
12-1: A Simple JavaScript Program in an HTML File | View source | Run Example |
13-1: Using the alert(), confirm(), and prompt() Methods | View source | |
13-2: A Digital Clock in the Status Line | View source | Run Example |
13-3: Determining Browser Vendor and Version | View source | |
13-4: Moving a Window | View source | Run Example |
13-5: Extracting Arguments from a URL | View source | |
13-6: A Navigation Bar Using the History and Location Objects | View source | |
13-7: A Frame Color Animation | View source | Run Example |
14-1: Dynamically Creating a Dialog Window | View source | Run Example |
14-2: Creating a Plain-Text Document | View source | Run Example |
14-3: An Animation Using Image Replacement | View source | Run Example |
14-4: An Animation Using the onLoad Event Handler | View source | Run Example |
14-5: Implementing a ToggleButton with Image Replacement | View source | Run Example |
14-6: Listing the Links in a Document | View source | |
14-7: Listing All Anchors | View source | |
15-1: An Event Monitoring Tool | View source | Run Example |
16-1: An HTML Form Containing All Form Elements | View source | Run Example |
16-2: Performing Form Validation | View source | Run Example |
17-1: Defining and Using Cascading Style Sheets | View source | Run Example |
17-2: Specifying Styles with JavaScript Syntax | View source | Run Example |
17-3: Dynamic Inline Styles in Internet Explorer | View source | Run Example |
17-4: Portable Dynamic HTML Elements with the DynEl Class | View source | |
17-5: Using the DynEl Class | View source | Run Example |
18-1: A Utility Class for Working with Cookies | View source | Run Example |
19-1: A Message for Browsers that do not Support JavaScript 1.1 | View source | |
19-2: Suppressing Version-Related Errors | View source | |
19-3: A Web Page to Test for JavaScript Compatibility | View source | |
19-4: A Script Hidden from Old Browsers | View source | |
20-1: Controlling an Applet with JavaScript | View source | |
20-2: Controlling a Plugin from JavaScript | View source | |
20-3: Scripting the Built-in Java Classes | View source | |
20-4: Using JavaScript from an Applet Method | View source | |
20-5: An OutputStream for Displaying HTML in a Browser Window | View source | |
21-1: An HTML File Prepared for Signing | View source | |
21-2: Requesting a Privilege | View source |