1. Trang chủ
  2. » Công Nghệ Thông Tin

JavaScript The Definitive Guide

607 313 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 607
Dung lượng 3,8 MB

Nội dung

JavaScript: The Definitive Guide By David Flannagan; ISBN: 1-56592-235-2, 637 pages. Second Edition, January 1997 Table of Contents Preface Chapter 1: Introduction to JavaScript 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. Chapter 2: Lexical Structure Chapter 3: Variables and Data Types Chapter 4: Expressions and Operators Chapter 5: Statements Chapter 6: Functions Chapter 7: Objects Chapter 8: Arrays Chapter 9: Further Topics in JavaScript 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. Chapter 10: Client-Side Program Structure Chapter 11: Windows and the JavaScript Name Space Chapter 12: Programming with Windows Chapter 13: The Navigator, Location, and History Objects Chapter 14: Documents and Their Contents Chapter 15: Saving State with Cookies Chapter 16: Special Effects with Images JavaScript: The Definitive Guide file:///C|/Oreilly Unix etc/O'Reilly Reference Library/web/jscript/index.html (1 of 2) [2002-04-12 13:45:10] Chapter 17: Forms and Form Elements Chapter 18: Compatibility Techniques Chapter 19: LiveConnect: JavaScript and Java Chapter 20: JavaScript Security Part III: Reference 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. JavaScript Reference Pages 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. Appendix A: JavaScript Resources on the Internet Appendix B: Known Bugs Appendix C: Differences between Navigator 2.0 and 3.0 Appendix D: JavaScript Incompatibilities in Internet Explorer 3.0 Appendix E: A Preview of Navigator 4.0 Appendix F: Persistent Client State:HTTP Cookies Appendix G: JavaScript and HTML Color Names and Values Appendix H: LiveConnected Navigator Plug-Ins Index 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. JavaScript: The Definitive Guide file:///C|/Oreilly Unix etc/O'Reilly Reference Library/web/jscript/index.html (2 of 2) [2002-04-12 13:45:10] Preface Preface Contents: Conventions Used in This Book Request for Comments Finding Examples Online Acknowledgments 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. ● Italics are used for emphasis, and to signify the first use of a term. Italics are also used for email ● Preface file:///C|/Oreilly Unix etc/O'Reilly Reference Library/web/jscript/ch00_01.html (1 of 2) [2002-04-12 13:45:11] 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. ● 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 Preface file:///C|/Oreilly Unix etc/O'Reilly Reference Library/web/jscript/ch00_01.html (2 of 2) [2002-04-12 13:45:11] Preface Request for Comments Please help us at O'Reilly to improve future editions by reporting any errors, inaccuracies, bugs, misleading or confusing statements, and plain old typos that you find anywhere in the book. Email your bug reports and comments to us at: bookquestions@ora.com. Please also let us know what we can do to make the book more useful to you. We take your comments seriously, and will try to incorporate reasonable suggestions into future editions of the book. You can reach us at: O'Reilly & Associates, Inc. 101 Morris Street Sebastopol, CA 95472 1-800-998-9938 (in the US or Canada) 1-707-829-0515 (international/local) 1-707-829-0104 (FAX) Conventions Used in This Book Finding Examples Online [Preface] Request for Comments file:///C|/Oreilly Unix etc/O'Reilly Reference Library/web/jscript/ch00_02.html [2002-04-12 13:45:11] Preface Finding Examples Online The examples used in this book are available via anonymous FTP on O'Reilly's FTP server. They may be found at: ftp://ftp.ora.com/pub/examples/nutshell/javascript They are also available on this CD-ROM. Request for Comments Acknowledgments [Preface] Finding Examples Online file:///C|/Oreilly Unix etc/O'Reilly Reference Library/web/jscript/ch00_03.html [2002-04-12 13:45:11] Preface Acknowledgments Writing this book would not have been nearly as exciting if Brendan Eich and his team at Netscape had not kept adding new features as I wrote! 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 helpful comments on the beta edition of this book. Nick Thompson and Richard Yaker at Netscape were also very helpful during the development of the book. Nick answered many of my questions about LiveConnect, and took the time to review and comment on a draft of Chapter 19, LiveConnect: JavaScript and Java. Richard found answers for me to many miscellaneous questions, and also provided me with the list of known bugs that are described in Appendix B, Known Bugs. Lynn Rollins, a partner at R&B Communications, and a contractor for Netscape, pointed out errors in the Beta edition of the book and also shared with me some of the less publicized features of JavaScript in Navigator 3.0. Much of my information about Internet Explorer comes from Shon Katzenberger Ph.D., Larry Sullivan, and Dave C. Mitchell, three of the primary developers of Microsoft's version of JavaScript. Shon and Larry are the Software Design Engineers who developed Microsoft's version of the JavaScript interpreter and Microsoft's version of the JavaScript client-side object model, respectively. Dave was the Test Lead for the project. All three reviewed the Beta edition of the book and provided me a wealth of information about Internet Explorer that was simply lacking before. Dave was particularly helpful in answering my last minute questions about IE's capabilities. Neil Berkman, a software engineer at Bay Networks in Billerica, MA, as well as Andrew Schulman and Terry Allen at O'Reilly were technical reviewers for the Beta edition. Their comments made that edition (and therefore this one) stronger and more accurate. Andrew was also the editor for the Beta edition of this book, and Frank Willison is editor of the current edition. I am grateful to them both. David Futato was the production manager for this edition of the book and the last. He coordinated the whole process of production, and for the Beta edition, it was he who worked weekends and nights in order to give me time to squeeze the last few new Beta 6 features in. Chris Reilley produced the figures for the book. Edie Freedman designed the cover, and Nancy Priest and Mary Jane Walsh designed the internal format, which was implemented by Lenny Muellner, with help from Erik Ray. Seth Maislin indexed this book. Finally, my thanks, as always and for so many reasons, to Christie. [Preface] Acknowledgments file:///C|/Oreilly Unix etc/O'Reilly Reference Library/web/jscript/ch00_04.html (1 of 2) [2002-04-12 13:45:11] David Flanagan November 1996 Finding Examples Online Introduction to JavaScript [Preface] Acknowledgments file:///C|/Oreilly Unix etc/O'Reilly Reference Library/web/jscript/ch00_04.html (2 of 2) [2002-04-12 13:45:11] Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y Symbols and Numbers /2 constant : Math.SQRT1_2 constant : Math.SQRT2 & (bitwise and) operator : Bitwise And . && (logical and) operator Miscellaneous Differences Logical And . &{} for entities Core Language Changes JavaScript Entities ' (apostrophe) String Literals Escape Sequences in String Literals * (multiplication) operator : Multiplication (*) \ (backslash) : Escape Sequences in String Literals != (inequality) operator : Inequality (!=) ! (logical not) operator : Logical Not (!) [] (brackets) Arrays Array and Object Access Operators for .in Objects as Associative Arrays Reading and Writing Array Elements Conversions to Objects ^ (bitwise exclusive or) operator : Bitwise Xor (^) , (comma) operator The Comma Operator (,) Index file:///C|/Oreilly Unix etc/O'Reilly Reference Library/web/jscript/index/idx_0.html (1 of 4) [2002-04-12 13:45:11] for {} (curly braces) Compound Statements function $ (dollar sign) : Identifiers . (dot) operator Array and Object Access Operators Reading and Writing Object Properties Arrays in Navigator 2.0 Conversions to Objects XX_DQUOTE_XX (double quote) : String Literals = (assignment) operator Equality (==) Assignment Operators The assign() Method combined with operations : Assignment with Operation == (equality) operator : Equality (==) > (greater than) operator Greater Than (>) String Operators >= (greater than or equal) operator Greater Than or Equal (>=) String Operators >> (shift right with sign) operator : Shift Right with Sign (>>) >>> (shift right zero fill) operator : Shift Right Zero Fill (>>>) - (minus) operator : Subtraction (-) - (negation) operator : Unary Negation (-) -- (decrement) operator : Decrement (--) < (less than) operator Less Than (<) String Operators <!-- --> (comment tags) Comments Hiding Scripts from Old Browsers Index file:///C|/Oreilly Unix etc/O'Reilly Reference Library/web/jscript/index/idx_0.html (2 of 4) [2002-04-12 13:45:11] [...]... book), you may be able to follow the logic behind the tax computation After the definition of the compute() function, we reach the end of the JavaScript The rest of the file consists of HTML, but this does not mean that JavaScript is not involved After some brief instructions to the user, the HTML begins to define the form displayed by the program The elements of the form are contained within... named compute() This is the function that computes the estimated tax you'll have to pay It doesn't just perform the computation, however It also reads the user's input from the form, and stores the result of the tax computation, along with intermediate results in the computation back into the form The variable f in this function refers to the HTML form, and the various elements of the form are accessed... the user's browsing history, simulating the action of the browser's Forward and Back buttons Finally, yet another method of the Window object allows JavaScript to display arbitrary messages to the user in the status line of any browser window Interact with Document Content The JavaScript Document object, and the objects it contains, allow programs to read, and sometimes interact with, portions of the. .. Navigator 3.0, JavaScript uses the navigator.plugins[] array to specify which "plug-ins" are installed in the browser; JavaScript uses the navigator.mimeTypes[] array to specify which MIME data formats are recognized by the browser q In Navigator 3.0, the scroll() method of the Window object allows JavaScript programs to scroll windows in the X and Y dimensions JavaScript Myths What JavaScript Can't... 13:45:11] [Chapter 1] Introduction to JavaScript Chapter 1 1 Introduction to JavaScript Contents: Executable Content: JavaScript in a Web Page JavaScript Myths What JavaScript Can Do What JavaScript Can't Do An Example: Calculating Your Taxes with JavaScript Flavors and Versions of JavaScript JavaScript Security Using the Rest of This Book Exploring JavaScript JavaScript is a lightweight interpreted... clicked the button')"> Figure 1.2: The JavaScript response to an event The onClick attribute shown in Example 1.2 is an HTML extension added by Netscape specifically for client-side JavaScript All JavaScript event handlers are defined with HTML attributes like this one The value of the onClick attribute is a string of JavaScript code to be executed when the user clicks the button In this case, the. .. JavaScript 1.0 and 1.1 There are currently two versions of the core JavaScript language The version that was included in Navigator 2.0 is JavaScript 1.0 The version that is in the current JSRef and in Navigator 3.0 is 1.1 When Navigator 4.0 is released, it will contain JavaScript 1.2 There are some significant differences between these various versions of the language For example, JavaScript 1.1 provides... interpreter is embedded in a web browser, the result is client-side JavaScript This is by far the most common "flavor" of JavaScript; when most people refer to JavaScript, they usually mean client-side JavaScript This book documents client-side JavaScript, along with the core JavaScript language that client-side JavaScript incorporates As of this writing, there are only two browsers, Netscape Navigator... only true when the script reading the list of links (or other information) was loaded from the same web server as the page containing the links Because of this security restriction, you currently cannot download an arbitrary page off the Web, and have JavaScript return you an array of the hypertext links on that page i.e., you cannot write a web crawler in JavaScript See Chapter 20, JavaScript Security,... f.income.value to refer to the string that the user entered in the income field The names for these fields will be assigned when the form is itself defined Note that this compute() function both reads and writes the value of expressions like f.income.value and f.standard.checked querying and setting the values displayed in the form If you follow the comments, and refer occasionally to the reference section . Search the text of JavaScript: The Definitive Guide. Copyright © 1996, 1997 O'Reilly & Associates. All Rights Reserved. JavaScript: The Definitive Guide. 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.

Ngày đăng: 04/11/2013, 11:15

TỪ KHÓA LIÊN QUAN