Javascript.pdf

(6494 KB) Pobierz
JavaScript: The Definitive Guide
JavaScript: The Definitive Guide
By David Flannagan; ISBN: 1-56592-235-2, 637 pages.
Second Edition, January 1997
Table of Contents
Part I: Core JavaScript
This part of the book, Chapters 2 through 9, documents the core JavaScript language, as it is used in web
browsers, web servers, and even in standalone JavaScript implementations. This part is a JavaScript
language reference, and after you read through it once to learn the language, you may find yourself
referring to it to refresh your memory about some of the trickier points.
Part II: Client-Side JavaScript
This part of the book, Chapters 10 through 20, documents JavaScript as it is implemented in web
browsers. These chapters introduce a host of new JavaScript objects which represent the web browser
and the contents of HTML documents. There are quite a few examples showing typical uses of these new
objects. You will find it helpful to study these examples carefully.
http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/web/jscript/ (1 of 2) [2/7/2001 3:48:14 PM]
402573674.013.png 402573674.014.png
JavaScript: The Definitive Guide
This part of the book is a complete reference to all of the objects, properties, functions, methods, and
event handlers in client-side JavaScript and in the core JavaScript language. The first few pages of this
part explain how to use this reference and provide a table of contents for it.
Part IV: Appendices
This part summarizes the differences between JavaScript in versions of Netscape Navigator, as well as
the differences in the version of JavaScript implemented in Microsoft Internet Explorer. It also contains a
list of known JavaScript bugs, the Netscape specification for Internet "cookies," and other important
details useful to the serious JavaScript programmer.
Examples - Warning: this directory includes long filenames which may confuse some older
operating systems (notably Windows 3.1).
Search the text of JavaScript: The Definitive Guide .
Copyright © 1996, 1997 O'Reilly & Associates. All Rights Reserved.
http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/web/jscript/ (2 of 2) [2/7/2001 3:48:14 PM]
402573674.015.png 402573674.016.png
Preface
Preface
Preface
Contents:
Conventions Used in This Book
In recent months, the pace of technical innovation has shot through the roof. It's been said that the
Internet has turned "man-months" into "web-weeks." It's hard to keep up!
When Netscape released a final version of Navigator 2.0, I imagined that JavaScript would finally be
stable, and that the time was ripe for a book documenting it. Soon after I started writing, a beta release of
Netscape 3.0 was announced. It seems like I've been playing catch-up ever since. In order to keep up
with this rapidly evolving language, we printed a "beta edition" of this book which documented the final
beta release of Navigator 3.0.
With the beta edition released, I was able to catch my breath and really document JavaScript the way it
needed to be documented. This edition is far superior to the last. It is over one hundred pages longer and
contains several new chapters, many practical new examples, far fewer errors, and dramatically improved
coverage of cookies, the Image object, LiveConnect, and other topics.
Fortunately (for my sanity), this edition of the book goes to print before the first beta version of
Navigator 4.0, a.k.a. Communicator, is released. The word is that there will be a lot of powerful and
interesting new JavaScript features in Navigator 4.0, and you can be sure that we'll update this book to
cover them when the final version of 4.0 comes out. In the meantime, I hope you'll agree that this book is
truly the definitive guide to JavaScript.
Conventions Used in This Book
I use the following formatting conventions in this book:
Bold is used for headings in the text, and occasionally to refer to particular keys on a computer
keyboard or to portions of user interfaces, such as the Back button or the Options menu.
l
Italics are used for emphasis, and to signify the first use of a term. Italics are also used for email
http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/web/jscript/ch00_01.html (1 of 2) [2/7/2001 3:48:21 PM]
l
402573674.001.png 402573674.002.png 402573674.003.png
Preface
l
addresses, web sites, FTP sites, file and directory names, and newsgroups. Furthermore, italics are
used in this book for the names of Java classes, to help keep Java class names distinct from
JavaScript names.
Letter Gothic is used in all JavaScript code and HTML text listings, and generally for
anything that you would type literally when programming.
l
Letter Gothic Oblique is used for the name of function arguments, and generally as a
placeholder to indicate an item that would be replaced with an actual value in your programs. It is
also used for comments in Javascript code.
Request for Comments
http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/web/jscript/ch00_01.html (2 of 2) [2/7/2001 3:48:21 PM]
402573674.004.png 402573674.005.png 402573674.006.png 402573674.007.png 402573674.008.png
[Chapter 1] Introduction to JavaScript
Chapter 1
1. Introduction to JavaScript
JavaScript is a lightweight interpreted programming language with rudimentary object-oriented
capabilities. The general-purpose core of the language has been embedded in Netscape Navigator and
other web browsers and embellished for web programming with the addition of objects that represent the
web browser window and its contents. This "client-side" version of JavaScript allows "executable
content" to be included in web pages--it means that a web page need no longer be static HTML, but can
include dynamic programs that interact with the user, control the browser, and dynamically create HTML
content.
Syntactically, the core JavaScript language resembles C, C++ and Java, with programming constructs
such as the if statement, the while loop, and the && operator. The similarity ends with this syntactic
resemblance, however. JavaScript is an untyped language, which means that variables do not have to
have a type specified. Objects in JavaScript are more like Perl's associative array than they are like
structures in C or objects in C++ or Java. Also, as mentioned, JavaScript is a purely interpreted language,
unlike C and C++, which are compiled, and unlike Java, which is compiled to byte-code before being
interpreted.
This chapter is a quick overview of JavaScript; it explains what JavaScript can do and also what it can't,
and exposes some myths about the language. The chapter demonstrates web programming with some
real-world JavaScript examples, explains the many versions of JavaScript, and also addresses security
concerns.
http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/web/jscript/ch01_01.html (1 of 4) [2/7/2001 3:48:29 PM]
402573674.009.png 402573674.010.png 402573674.011.png 402573674.012.png
Zgłoś jeśli naruszono regulamin