JavaScript - The Definitive Guide(2).pdf

(3585 KB) Pobierz
432369137 UNPDF
E
-Book Ripped by lilmeanman
Enjoy! http://www.magic-html.com
-- Free Apps, E-Books, ETC
Lilmeanman
Digitally signed by Lilmeanman
DN: CN = Lilmeanman, C = US, O = Lilmeanman UNltd, OU = Lilmeanman UNltd
Reason: I attest to the accuracy and integrity of this document
Date: 2004.08.31 17:19:43 -06'00'
432369137.001.png 432369137.002.png
Dedication
This book is dedicated to all who teach peace and
resist violence.
Preface
There have been many changes in the world of web programming with JavaScript
since the third edition of this book was published, including:
! Second and third editions of the ECMA-262 standard have been published,
updating the core JavaScript language. Conformant versions of Netscape's
JavaScript interpreter and Microsoft's JScript interpreter have been released.
! The source code for Netscape's JavaScript interpreters (one written in C and one
written in Java ) has been released as open source and is available to anyone
who wants to embed a scripting language in his application.
! The World Wide Web Consortium (W3C) has published two versions (or levels)
of a Document Object Model (DOM) standard. Recent browsers support this
standard (to varying degrees) and allow client-side JavaScript to interact with
document content to produce sophisticated Dynamic HTML (DHTML) effects.
Support for other W3C standards, such as HTML 4, CSS1, and CSS2, has also
become widespread.
! The Mozilla organization, using source code originally contributed by Netscape,
has produced a good fifth-generation browser. At the time of this writing, the
Mozilla browser is not yet at the 1.0 release level, but the browser is mature
enough that Netscape has based its 6.0 and 6.1 browsers upon the Mozilla code
base.
! Microsoft's Internet Explorer has become the overwhelmingly dominant browser
on desktop systems. However, the Netscape/Mozilla browser remains relevant to
web developers, especially because of its superior support for web standards. In
addition, minor browsers such as Opera ( http://www.opera.com ) and Konquerer
( http://www.konqueror.org ) should be seen as equally relevant.
! Web browsers (and JavaScript interpreters) are no longer confined to the desktop
but have migrated to PDAs and even cell phones.
In summary, the core JavaScript language has matured. It has been standardized and is
used in a wider variety of environments than it was previously. The collapse of
Netscape's market share has allowed the universe of desktop web browsers to expand,
and JavaScript-enabled web browsers have also become available on non-desktop
platforms. There has been a distinct, if not complete, move toward web standards. The
(partial) implementation of the DOM standard in recent browsers gives web developers a
long-awaited vendor-independent API to which they can code.
432369137.003.png 432369137.004.png
What's New in the Fourth Edition
This edition of JavaScript: The Definitive Guide has been thoroughly updated in light of
the changes I just described. Major new features include complete coverage of JavaScript
1.5 and the third edition of the ECMA-262 standard on which it is based, and complete
coverage of the Level 2 DOM standard.
Throughout the book, the focus has shifted from documenting particular JavaScript and
browser implementations ( JavaScript 1.2, Netscape 4, Internet Explorer 5, etc.) to
documenting the standards upon which those implementations are (or ought to be) based.
Because of the proliferation of implementations, it is no longer practical for any one book
to attempt to document -- or for any one developer to attempt to understand -- every
feature, proprietary extension, quirk, and bug of every implementation. Focusing on the
specifications instead of the implementations makes this book easier to use and, if you
take the same approach, will make your JavaScript code more portable and maintainable.
You'll particularly notice the increased emphasis on standards in the new material on core
JavaScript and the DOM.
Another major change in this edition is that the reference section has been split into three
distinct parts. First, the core JavaScript material has been separated from the client-side
JavaScript material ( Part IV ) and placed in a section of its own ( Part III ). This division is
for the convenience of JavaScript programmers who are working with the language in an
environment other than a web browser and who are not interested in client-side
JavaScript.
Second, the new material documenting the W3C DOM has been placed in a section of its
own ( Part V ), separate from the existing client-side JavaScript material. The DOM
standard defines an API that is quite distinct from the "legacy" API of traditional client-
side JavaScript. Depending on the browser platforms they are targeting, developers
typically use one API or the other and usually do not need to switch back and forth.
Keeping these two APIs distinct also preserves the organization of the existing client-side
reference material, which is convenient for readers of the third edition who upgrade to
this edition.
In order to accommodate all the new material without making the book much, much
larger, I've gotten rid of reference pages for the trivial properties of objects. These
properties are already described once on the reference page for the object, and putting
another description in a reference page of its own was redundant and wasteful. Properties
that require substantial description, as well as all methods, still have reference pages of
their own. Furthermore, the design wizards at O'Reilly have created a new interior design
for the book that remains easy and pleasant to read but takes up less space.
Conventions Used in This Book
I use the following formatting conventions in this book:
Bold
Is occasionally used to refer to particular keys on a computer keyboard or to
portions of a user interface, such as the Back button or the Options menu.
Italic
Is used for emphasis and to signify the first use of a term. Italic is also used for
email addresses, web sites, FTP sites, file and directory names, and newsgroups.
Finally, italic is used in this book for the names of Java classes, to help keep Java
class names distinct from JavaScript names.
Constant width
Is used in all JavaScript code and HTML text listings, and generally for anything
that you would type literally when programming.
Constant width italic
Is used for the names of function arguments, and generally as a placeholder to
indicate an item that should be replaced with an actual value in your program.
Finding the Examples Online
The examples printed in this book are available for download from the book's web site.
Follow the Examples link from the book's catalog page:
http://www.oreilly.com/catalog/jscript4/
Acknowledgments
Brendan Eich of the Mozilla organization is the originator and chief innovator of
JavaScript. I, and many JavaScript developers, owe Brendan a tremendous debt of
gratitude for developing JavaScript and for taking the time out of his crazy schedule to
answer our questions and even solicit our input. Besides patiently answering my many
questions, Brendan also read and provided very helpful comments on the first and third
editions of this book.
This book has been blessed with top-notch technical reviewers, whose comments have
gone a long way toward making it a stronger, more accurate book. Waldemar Horwat at
Zgłoś jeśli naruszono regulamin