📄 index.html
字号:
google_ad_channel ="";//--></script><script type="text/javascript" src="../../pagead2.googlesyndication.com/pagead/show_ads.js" tppabs="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><p>The links below display the source code for the 124 numberedexamples in the 5th edition of my book <i>JavaScript: TheDefinitive Guide</i>. Cut-and-paste the code in order totry it out yourself and use it in your own programs.<p>See the <ahref="javascript:if(confirm('http://www.oreilly.com/pub/a/oreilly/ask_tim/2001/codepolicy.html \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.oreilly.com/pub/a/oreilly/ask_tim/2001/codepolicy.html'" tppabs="http://www.oreilly.com/pub/a/oreilly/ask_tim/2001/codepolicy.html">"O'Reilly Policy on Re-Use of Code Examples from Books"</a>for details on how you may and may not use these examples.In most cases, it suffices to simply provide suitableattribution, in the source code and documentation of yourprogram, with a comment like the following:</p><pre>// This code is from the book JavaScript: The Definitive Guide, 5th Edition,// by David Flanagan. Copyright 2006 O'Reilly Media, Inc. (ISBN #0596101996)</pre><p>Please note that the examples are not production code. Theyare provided "as-is" and come with no warranty of any kind.</p><p>You can download the entire bundle of examples from<a href="javascript:if(confirm('http://www.oreilly.com/catalog/jscript5 \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.oreilly.com/catalog/jscript5'" tppabs="http://www.oreilly.com/catalog/jscript5">the O'Reilly website.</a><table><tr><th colspan="2" align="left">Chapter 1: Introduction to JavaScript</th></tr><tr><td><a href="display.php-n=1-1&f=01-01.html" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=1-1&f=01/01.html">1-1</a></td><td> A simple JavaScript program</td></tr><tr><td><a href="display.php-n=1-2&f=01-02.html" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=1-2&f=01/02.html">1-2</a></td><td> An HTML button with a JavaScript event handler defined</td></tr> <tr><td><a href="display.php-n=1-3&f=01-03.html" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=1-3&f=01/03.html">1-3</a></td><td> Computing loan payments with JavaScript</td></tr><tr><th colspan="2" align="left">Chapter 3: Datatypes and Values</th></tr><tr><td><a href="display.php-n=3-1&f=03-01.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=3-1&f=03/01.js">3-1</a></td><td> Copying, passing, and comparing by value</td></tr><tr><td><a href="display.php-n=3-2&f=03-02.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=3-2&f=03/02.js">3-2</a></td><td> Copying, passing, and comparing by reference</td></tr><tr><td><a href="display.php-n=3-3&f=03-03.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=3-3&f=03/03.js">3-3</a></td><td> References themselves are passed by value</td></tr><tr><td><a href="display.php-n=3-4&f=03-04.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=3-4&f=03/04.js">3-4</a></td><td> Are strings compared by value or by reference?</td></tr><tr><th colspan="2" align="left">Chapter 8: Functions</th></tr><tr><td><a href="display.php-n=8-1&f=08-01.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=8-1&f=08/01.js">8-1</a></td><td> Defining JavaScript functions</td></tr><tr><td><a href="display.php-n=8-2&f=08-02.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=8-2&f=08/02.js">8-2</a></td><td> Using functions as data</td></tr><tr><td><a href="display.php-n=8-3&f=08-03.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=8-3&f=08/03.js">8-3</a></td><td> Object utility functions</td></tr><tr><td><a href="display.php-n=8-4&f=08-04.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=8-4&f=08/04.js">8-4</a></td><td> Array utility functions</td></tr><tr><td><a href="display.php-n=8-5&f=08-05.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=8-5&f=08/05.js">8-5</a></td><td> Utility functions for functions</td></tr><tr><td><a href="display.php-n=8-6&f=08-06.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=8-6&f=08/06.js">8-6</a></td><td> Private properties with closures</td></tr><tr><td><a href="display.php-n=8-7&f=08-07.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=8-7&f=08/07.js">8-7</a></td><td> Breakpoints using closures</td></tr><tr><th colspan="2" align="left">Chapter 9: Classes, Constructors, and Prototypes</th></tr><tr><td><a href="display.php-n=9-1&f=09-01.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=9-1&f=09/01.js">9-1</a></td><td> A circle class</td></tr><tr><td><a href="display.php-n=9-2&f=09-02.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=9-2&f=09/02.js">9-2</a></td><td> A complex number class</td></tr><tr><td><a href="display.php-n=9-3&f=09-03.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=9-3&f=09/03.js">9-3</a></td><td> Subclassing a JavaScript class</td></tr><tr><td><a href="display.php-n=9-4&f=09-04.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=9-4&f=09/04.js">9-4</a></td><td> Borrowing methods from one class for use by another</td></tr><tr><td><a href="display.php-n=9-5&f=09-05.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=9-5&f=09/05.js">9-5</a></td><td> Mixin classes with generic methods for borrowing</td></tr><tr><td><a href="display.php-n=9-6&f=09-06.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=9-6&f=09/06.js">9-6</a></td><td> Enhanced typeof testing</td></tr><tr><td><a href="display.php-n=9-7&f=09-07.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=9-7&f=09/07.js">9-7</a></td><td> Testing whether an object borrows the methods of a class</td></tr><tr><td><a href="display.php-n=9-8&f=09-08.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=9-8&f=09/08.js">9-8</a></td><td> Testing whether an object provides methods</td></tr><tr><td><a href="display.php-n=9-9&f=09-09.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=9-9&f=09/09.js">9-9</a></td><td> Testing for array-like objects</td></tr><tr><td><a href="display.php-n=9-10&f=09-defineClass.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=9-10&f=09/defineClass.js">9-10</a></td><td> A utility function for defining classes</td></tr><tr><td><a href="display.php-n=9-11&f=09-11.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=9-11&f=09/11.js">9-11</a></td><td> Using the defineClass() method</td></tr><tr><th colspan="2" align="left">Chapter 10: Modules and Namespaces</th></tr><tr><td><a href="display.php-n=10-1&f=10-01.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=10-1&f=10/01.js">10-1</a></td><td> Creating a namespace based on a domain name</td></tr><tr><td><a href="display.php-n=10-2&f=10-02.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=10-2&f=10/02.js">10-2</a></td><td> A complex number class as a module</td></tr><tr><td><a href="display.php-n=10-3&f=10-03.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=10-3&f=10/03.js">10-3</a></td><td> A module of shapes classes</td></tr><tr><td><a href="display.php-n=10-4&f=10-04.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=10-4&f=10/04.js">10-4</a></td><td> Defining a private namespace with a closure</td></tr><tr><td><a href="display.php-n=10-5&f=10-Module.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=10-5&f=10/Module.js">10-5</a></td><td> A module of module-related utilities</td></tr><tr><th colspan="2" align="left">Chapter 12: Scripting Java</th></tr><tr><td><a href="display.php-n=12-1&f=12-RunScript.java.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=12-1&f=12/RunScript.java">12-1</a></td><td> A Java program for running JavaScript scripts</td></tr><tr><td><a href="display.php-n=12-2&f=12-Configuration.java.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=12-2&f=12/Configuration.java">12-2</a></td><td>A Java configuration file utility that interprets JavaScript expressions</td></tr><tr><td><a href="display.php-n=12-3&f=12-Keys.java.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=12-3&f=12/Keys.java">12-3</a></td><td> Implementing a Java interface with JavaScript code.</td></tr><tr><th colspan="2" align="left">Chapter 14: Scripting Browser Windows</th></tr><tr><td><a href="display.php-n=14-1&f=14-01.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=14-1&f=14/01.js">14-1</a></td><td> Extracting arguments from a URL</td></tr><tr><td><a href="display.php-n=14-2&f=14-Geometry.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=14-2&f=14/Geometry.js">14-2</a></td><td> Portably querying window geometry</td></tr><tr><td><a href="display.php-n=14-3&f=14-browser.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=14-3&f=14/browser.js">14-3</a></td><td> Determining browser vendor and version</td></tr><tr><td><a href="display.php-n=14-4&f=14-04.html" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=14-4&f=14/04.html">14-4</a></td><td> Creating and manipulating windows</td></tr><tr><td><a href="display.php-n=14-5&f=14-05.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=14-5&f=14/05.js">14-5</a></td><td> Using the confirm() method</td></tr><tr><td><a href="display.php-n=14-6&f=14-06.html" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=14-6&f=14/06.html">14-6</a></td><td> A tasteful status line animation</td></tr><tr><td><a href="display.php-n=14-7&f=14-navigation.html" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=14-7&f=14/navigation.html">14-7</a></td><td> A navigation bar</td></tr><tr><th colspan="2" align="left">Chapter 15: Scripting Documents</th></tr><tr><td><a href="display.php-n=15-1&f=15-01.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=15-1&f=15/01.js">15-1</a></td><td> Listing all anchors</td></tr><tr><td><a href="display.php-n=15-2&f=15-02.html" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=15-2&f=15/02.html">15-2</a></td><td> Traversing the nodes of a document</td></tr><tr><td><a href="display.php-n=15-3&f=15-03.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=15-3&f=15/03.js">15-3</a></td><td> Obtaining all text beneath a DOM node</td></tr><tr><td><a href="display.php-n=15-4&f=15-04.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=15-4&f=15/04.js">15-4</a></td><td> Selecting HTML elements by class or tag name</td></tr><tr><td><a href="display.php-n=15-5&f=15-05.html" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=15-5&f=15/05.html">15-5</a></td><td> Alphabetizing the elements of a list</td></tr><tr><td><a href="display.php-n=15-6&f=15-06.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=15-6&f=15/06.js">15-6</a></td><td> Converting document content to uppercase</td></tr><tr><td><a href="display.php-n=15-7&f=15-07.html" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=15-7&f=15/07.html">15-7</a></td><td> Reparenting a node to a <b> element</td></tr><tr><td><a href="display.php-n=15-8&f=15-08.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=15-8&f=15/08.js">15-8</a></td><td> Using a DocumentFragment</td></tr><tr><td><a href="display.php-n=15-9&f=15-Log.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=15-9&f=15/Log.js">15-9</a></td><td> A logging facility for client-side JavaScript</td></tr><tr><td><a href="display.php-n=15-10&f=15-Make.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=15-10&f=15/Make.js">15-10</a></td><td> Element creation utility functions</td></tr><tr><td><a href="display.php-n=15-11&f=15-TOC.js.htm" tppabs="http://www.davidflanagan.com/javascript5/display.php?n=15-11&f=15/TOC.js">15-11</a></td><td> Automatically generating a table of contents</td></tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -