JavaScript was originally intended to be a scripting interface between a web page loaded in the browser client (Netscape Navigator at the time), and the application on the server. Since its introduction in 1995, JavaScript has become a key component of web development, and has found uses elsewhere as well. This book covers the JavaScript language, from its most primitive data types that have been around since the beginnings of the language, to its most complex features, including those involved with Ajax and DHTML. By the end of the book, you will have the basics you need to work with even the most sophisticated libraries and web applications. AudienceReaders of this book should be familiar with web page technology, including CSS and HTML/XHTML. You may well have seen some JavaScript in that work. Previous programming experience isn't required, though some sections may require extra review if you have no previous exposure to programming. This book should help:
Assumptions and ApproachAs stated earlier, this book assumes you have experience with (X)HTML and CSS, as well as a general understanding of how web applications work. Programming experience isn't necessary, but the book covers all aspects of JavaScript, some of which are relatively sophisticated. Though the heavier pieces are few, you will need to understand JavaScript enough to work with the newer Ajax libraries. The book is broken into four sections: Chapters 1 through 3 provide an introduction to the structure of a JavaScript application, including the simple data types supported in the language, as well as the basic statements and control structures. These establish a baseline of understanding of the language for the sections that follow. Chapters 4 through 8 introduce the main JavaScript objects, including the all-important function, script access for web-page forms, event handling, scripting security, and working with cookies. Combined, these topics comprise the core of JavaScript, and with these chapters, you can validate form elements, set and retrieve cookies, capture and provide functionality for events, and even create JavaScript libraries. The functionality covered in these chapters has been basic to JavaScript for 10 years, and will remain so for at least another 10. Chapters 9 through 11 delve into the more sophisticated aspects of web-page development. These chapters cover the Browser Object Model and the newer Document Object Model, and show how you can create your own custom objects. Understanding these models is essential if you wish to create new windows, or individually access, modify, or even dynamically create any page element. In addition, with custom objects, you can then move beyond the capabilities that are prebuilt into either language or browser. Chapters 12 through 14 get into the advanced uses of JavaScript, including DHTML, Ajax, and some of the many wonderful new libraries that support both.
Conventions Used in This BookThe following typographical conventions are used in this book:
Web sites and pages are mentioned in this book to help you locate online information that might be useful. Normally both the address (URL) and the name (title, heading) of a page are mentioned. Some addresses are relatively complicated, but you can probably locate the pages easier using your favorite search engine to find a page by its name, typically by writing it inside quotation marks. This may also help if the page cannot be found by its address; it may have moved elsewhere, so the name may still work. Using Code ExamplesThis book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you're reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O'Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product's documentation does require permission. We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: "Learning JavaScript by Shelley Powers. Copyright 2007 O'Reilly Media, Inc., 978-0-596-52746-4." If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com. How to Contact UsPlease address comments and questions concerning this book to the publisher:
We have a web page for this book that lists errata, examples, and any additional information. You can access this page at:
You can also visit the author's web site for the book at:
To comment or ask technical questions about this book, send email to:
For more information about our books, conferences, Resource Centers, and the O'Reilly Network, see our web site at:
Safari® EnabledWhen you see a Safari® Enabled icon on the cover of your favorite technology book, that means the book is available online through the O'Reilly Network Safari Bookshelf. Safari offers a solution that's better than e-books. It's a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at http://safari.oreilly.com. AcknowledgmentsWith some books, you have a terrific team behind you, and this book is one of those. I want to thank my editor, Simon St.Laurent, for his patience, enthusiasm, and guidance as the book metamorphosed during the writing process. In addition, I want to thank the tech and content reviewers, Steven Champeon, Roy Owens, and Alan Herrell for their excellent suggestions, as well as help in finding the gotchas and rough spots. I also want to acknowledge Rachel Monaghan, production editor for this book; Mary Anne Weeks Mayo, copyeditor; Johnna VanHoose Dinse, indexer; and Marlowe Shaeffer, production manager. Finally, I want to send thanks to those who I have met online, in the tech community and out. You were in mind as I wrote the book. In a way, you can say this book was written for youyou know who you are. |