Professional Javascript for Web Developers 2nd Edition

dbjoy

贡献于2015-03-21

字数:0 关键词: JavaScript开发 Java

Professional JavaScript® for Web Developers, 2nd Edition www.wrox.com $49.99 USA $54.99 CAN Wrox Professional guides are planned and written by working programmers to meet the real-world needs of programmers, developers, and IT professionals. Focused and relevant, they address the issues technology professionals face every day. They provide examples, practical solutions, and expert education in new technologies, all designed to help programmers do a better job. Recommended Computer Book Categories Programming Languages JavaScript and VBScript ISBN: 978-0-470-22780-0 If you want to achieve JavaScript’s full potential, it is critical to understand its nature, history, and limitations. This book sets the stage by covering JavaScript from its very beginning to the present-day incarnations that include support for the DOM and Ajax. It also shows you how to extend this powerful language to meet specific needs and create seamless client-server communication without intermediaries such as Java or hidden frames. You’ll explore basic concepts of JavaScript including its version of object-oriented programming, inheritance, and its use in HTML and XHTML. A detailed discussion of the components that make up a JavaScript implementation follows, with specific focus on standards such as ECMAScript and DOM. All three levels of DOM are explained, including advanced topics such as event simulation, XML parsing, and XPath queries. You’ll also learn how to utilize regular expressions and build dynamic user interfaces. This valuable insight will help you apply JavaScript solutions to the business problems faced by Web developers everywhere. What you will learn from this book ● All of the details regarding JavaScript’s built-in reference types ● How to use object-oriented programming in JavaScript ● Ways to detect the client machine and its capabilities ● Debugging tools and techniques for each browser ● Steps for reading and manipulating XML data ● How to create a custom event framework ● Various techniques for storing data on the client machine ● Approaches to working with JavaScript in an enterprise environment Who this book is for This book is for Web developers who want to use JavaScript to dramatically improve the usability of their Web sites and Web applications and for those with programming experience, especially object-oriented programming experience. Enhance Your Knowledge Advance Your Career JavaScript ® for Web Developers Zakas Professional spine=1.68" 2nd Edition Updates, source code, and Wrox technical support at www.wrox.com Professional JavaScript® for Web Developers 2nd Edition Nicholas C. Zakas Wrox Programmer to ProgrammerTMWrox Programmer to ProgrammerTM Professional JavaScript® for Web Developers, 2nd Edition Enhance Your Knowledge Advance Your Career Professional JavaScript for Web Developers, 2nd Edition 978-0-470-22780-0 This updated bestseller offers an in-depth look at the JavaScript language, and covers such topics as debugging tools in Microsoft Visual Studio, FireBug, and Drosera; client-side data storage with cookies, the DOM, and Flash; client-side graphics with JavaScript including SVG, VML, and Canvas; and design patterns including creational, structural, and behavorial patterns. Professional Ajax, 2nd Edition 978-0-470-10949-6 Professional Ajax, 2nd Edition is written for Web application developers looking to enhance the usability of their web sites and Web applications and intermediate JavaScript developers looking to further understand the language. This second edition is updated to cover Prototype, jQuery, FireBug, Microsoft Fiddler, ASP.NET AJAX Extensions, and much more. Concise Guide to Dojo 978-0-470-45202-8 Dojo has rapidly become one of the hottest JavaScript based Web development frameworks. It provides you with the power and flexibility to create attractive and useful dynamic Web applications quickly and easily. In this fast-paced, code-intensive guide, you’ll discover how to quickly start taking advantage of Dojo. The pages are packed with useful information and insightful examples that will help you. Beginning JavaScript and CSS Development with jQuery 978-0-470-22779-4 Beginning JavaScript and CSS Development with jQuery presents the world of dynamic Web applications to Web developers from the standpoint of modern standards. The author shows new JavaScript developers how working with the standard jQuery library will help them to do more with less code and fewer errors. Beginning JavaScript, 3rd Edition 978-0-470-05151-1 This book aims to teach you all you need to know to start experimenting with JavaScript: what it is, how it works, and what you can do with it. Starting from the basic syntax, you'll move on to learn how to create powerful Web applications. Beginning CSS, 2nd Edition 978-0-470-17708-2 Updated and revised, this book offers a hands-on look at designing standards-based, large-scale, professional-level CSS Web sites. Understand designers’ processes from start to finish and gain insight into how designers overcome a site’s unique set of challenges and obstacles. Become comfortable with solving common problems, learn the best practices for using XHMTL with CSS, orchestrate a new look for a blog, tackle browser-compatibility issues, and develop functional navigational structures. Get more out of WROX.com Programmer to Programmer™ Interact Take an active role online by participating in our P2P forums Wrox Online Library Hundreds of our books are available online through Books24x7.com Wrox Blox Download short informational pieces and code to keep you up to date and out of trouble! Chapters on Demand Purchase individual book chapters in pdf format Join the Community Sign up for our free monthly newsletter at newsletter.wrox.com Browse Ready for more Wrox? We have books and e-books available on .NET, SQL Server, Java, XML, Visual Basic, C#/ C++, and much more! Contact Us. We always like to get feedback from our readers. Have a book idea? Need community support? Let us know by e-mailing wrox-partnerwithus@wrox.com spine=1.68" Professional JavaScript® for Web Developers Introduction .............................................................................................. xxix Chapter 1: What Is JavaScript? .......................................................................1 Chapter 2: JavaScript in HTML ......................................................................13 Chapter 3: Language Basics .........................................................................23 Chapter 4: Variables, Scope, and Memory ......................................................79 Chapter 5: Reference Types ..........................................................................97 Chapter 6: Object-Oriented Programming .....................................................151 Chapter 7: Anonymous Functions ................................................................183 Chapter 8: The Browser Object Model .........................................................201 Chapter 9: Client Detection ........................................................................229 Chapter 10: The Document Object Model ....................................................261 Chapter 11: DOM Levels 2 and 3 .................................................................317 Chapter 12: Events .....................................................................................365 Chapter 13: Scripting Forms .......................................................................433 Chapter 14: Error Handling and Debugging ..................................................465 Chapter 15: XML in JavaScript ....................................................................515 Chapter 16: ECMAScript for XML ................................................................547 Chapter 17: Ajax and JSON .........................................................................567 Chapter 18: Advanced Techniques ..............................................................589 Chapter 19: Client-Side Storage ..................................................................617 Chapter 20: Best Practices .........................................................................635 Chapter 21: Upcoming APIs ........................................................................669 Chapter 22: The Evolution of JavaScript ......................................................703 Appendix A: JavaScript Libraries ..................................................................759 Appendix B: JavaScript Tools ......................................................................765 Index .........................................................................................................773 ffirs.indd iffirs.indd i 12/8/08 12:02:05 PM12/8/08 12:02:05 PM ffirs.indd iiffirs.indd ii 12/8/08 12:02:06 PM12/8/08 12:02:06 PM Professional JavaScript® for Web Developers 2nd Edition ffirs.indd iiiffirs.indd iii 12/8/08 12:02:06 PM12/8/08 12:02:06 PM ffirs.indd ivffirs.indd iv 12/8/08 12:02:06 PM12/8/08 12:02:06 PM Professional JavaScript® for Web Developers 2nd Edition Nicholas C. Zakas Wiley Publishing, Inc. ffirs.indd vffirs.indd v 12/8/08 12:02:06 PM12/8/08 12:02:06 PM Professional JavaScript® for Web Developers, 2nd Edition Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-22780-0 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 Library of Congress Cataloging-in-Publication Data Zakas, Nicholas C. Professional JavaScript for web developers/Nicholas C. Zakas. — 2nd ed. p. cm. Includes index. ISBN 978-0-470-22780-0 (paper/website) 1. Web site development. 2. JavaScript (Computer program language) I. Title. TK5105.8885.J38Z34 2008 005.2'762 — dc22 2008045552 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. JavaScript is a registered trademark of Sun Microsystems, Inc. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. ffirs.indd viffirs.indd vi 12/8/08 12:02:07 PM12/8/08 12:02:07 PM Dedicated to my family: mom, dad, Greg, Yiayia, and Papou. We may be few in numbers, but we are mighty! Your constant love and support have made the past couple of years possible. ffirs.indd viiffirs.indd vii 12/8/08 12:02:07 PM12/8/08 12:02:07 PM ffirs.indd viiiffirs.indd viii 12/8/08 12:02:07 PM12/8/08 12:02:07 PM About the Author Nicholas C. Zakas has a B.S. in Computer Science from Merrimack College and an M.B.A. from Endicott College. He is the coauthor of Professional Ajax, Second Edition (Wiley, 2007) as well as dozens of online articles. Nicholas works for Yahoo! as a principal front-end engineer on Yahoo!’s front page and a contributor to the Yahoo! User Interface (YUI) Library. He has worked in web development for more than eight years, during which time he has helped develop web solutions in use at some of the largest companies in the world. Nicholas can be reached through his web site www.nczonline.net. ffirs.indd ixffirs.indd ix 12/8/08 12:02:07 PM12/8/08 12:02:07 PM ffirs.indd xffirs.indd x 12/8/08 12:02:07 PM12/8/08 12:02:07 PM Acquisitions Director Jim Minatel Senior Development Editor Kevin Kent Technical Editor Alexei Gorkov Development Editor Gus Miklos Production Editor Rebecca Coleman Copy Editors Foxxe Editorial Services, Candace English Editorial Manager Mary Beth Wakefield Production Manager Tim Tate Vice President and Executive Group Publisher Richard Swadley Vice President and Executive Publisher Joseph B. Wikert Project Coordinator, Cover Lynsey Stanford Proofreader Kathryn Duggan Indexer Jack Lewis Credits ffirs.indd xiffirs.indd xi 12/8/08 12:02:07 PM12/8/08 12:02:07 PM ffirs.indd xiiffirs.indd xii 12/8/08 12:02:07 PM12/8/08 12:02:07 PM Acknowledgments It takes many people to create a single book, and I’d like to thank some people here for their contributions to this work. First and foremost, thanks to everyone at Wiley for their support: Jim Minatel for once again putting his faith in me; Kevin Kent for dealing with the hectic outline rearrangements I tend to make throughout writing; and Alexei Gorkov, the best technical editor in the world, who makes sure that everything I say is 100-percent accurate. A big thanks to everyone who provided feedback on draft chapters: David Serduke, Julian Turner, Pete Frueh, Chris Klaiber, Stoyan Stefanov, Ross Harmes, and David Golightly. Your early feedback was really helpful in making this book what it is today. Last, thanks to Eric Miraglia for his contribution of a foreword. Eric is the reason I ended up at Yahoo!, and it has been a pleasure to work with him for the past two years. ffirs.indd xiiiffirs.indd xiii 12/8/08 12:02:07 PM12/8/08 12:02:07 PM ffirs.indd xivffirs.indd xiv 12/8/08 12:02:07 PM12/8/08 12:02:07 PM Contents Foreword xxvii Introduction xxix Chapter 1: What Is JavaScript? 1 A Short History 1 JavaScript Implementations 3 ECMAScript 3 The Document Object Model (DOM) 7 The Browser Object Model (BOM) 9 JavaScript Versions 10 Summary 11 Chapter 2: JavaScript in HTML 13 The