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

Beginning JavaScript 4th Edition 2010 pdf

793 896 1

Đ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 793
Dung lượng 6,05 MB

Nội dung

Wrox Programmer to Programmer™ Join the discussion @ p2p.wrox.com 4th Edition Beginning JavaScript ® Paul Wilton, Jeremy McPeak Beginning Wilton, McPeak $39.99 USA $47.99 CAN Web Development/JavaScript JavaScript ® Step-by-step guidance to creating powerful web apps with JavaScript 4th Edition wrox.com Programmer Forums Join our Programmer to Programmer forums to ask and answer programming questions about this book, join discussions on the hottest topics in the industry, and connect with fellow programmers from around the world. Code Downloads Take advantage of free code samples from this book, as well as code samples from hundreds of other books, all ready to use. Read More Find articles, ebooks, sample chapters and tables of contents for hundreds of books, and more reference resources on programming topics that matter to you. JavaScript allows you to enhance your web pages and web applications by providing dynamic, personalized, and interactive content. Serving as a great introduction to JavaScript, this book offers all you need to start using JavaScript on your web pages right away. It’s fully updated and covers utilizing JavaScript with the latest versions of the Internet Explorer ® , Firefox ® , and Safari ® browsers. • Walks you through the basics of JavaScript: what it is, how it works, and what you can do with it • Covers the various tools needed to create JavaScript web applications • Escorts you through selecting a single character from a string, converting character codes to a string, and copying string parts • Shows you how to join arrays, copy parts of an array, sort arrays, and reverse an array’s order • Explains how using a JavaScript framework (such as jQuery, Prototype, and MooTools) makes JavaScript programming faster and more efficient • Offers an in-depth look at Ajax • Reviews common mistakes, debugging, and error handling Paul Wilton owns his own company, providing online booking systems to vacation property owners, which is largely developed using JavaScript. Jeremy McPeak is a self-taught programmer who began his career by tinkering with web sites in 1998. He is the coauthor of Professional Ajax, 2nd Edition and several online articles covering topics such as XSLT, ASP .NET Web Forms, and C#. He is currently employed at an energy-based company building in-house conventional and web applications. Wrox Beginning guides are crafted to make learning programming languages and technologies easier than you think, providing a structured, tutorial format that will guide you through all the techniques involved. 525937_cover_2.indd 1525937_cover_2.indd 1 12/18/09 2:29 PM12/18/09 2:29 PM 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 Related Wrox Books Beginning CSS, 2nd Edition ISBN: 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. Beginning JavaScript and CSS Development with jQuery ISBN: 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. Concise Guide to Dojo ISBN: 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. JavaScript Programmer’s Reference ISBN: 978-0-470-34472-9 Both a tutorial and a reference guide for web developers, employ this complete JavaScript reference to help you understand JavaScript data types, variables, operators, expressions, and statements, work with JavaScript frameworks and data, and improve performance with Ajax. Professional Ajax, 2nd Edition ISBN: 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. Professional JavaScript for Web Developers, 2nd Edition ISBN: 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 JavaScript Frameworks: Prototype, YUI, ExtJS, Dojo and MooTools ISBN: 978-0-470-38459-6 This book offers a selection of some of the most active and most used JavaScript frameworks available, replete with practical examples and explanations of what each framework does best. You’ll look at common web development tasks and discover how each framework approaches that set of tasks, as well as learn how to use the features of each framework and avoid potential pitfalls. 525937_cover_2.indd 2525937_cover_2.indd 2 12/18/09 2:29 PM12/18/09 2:29 PM Beginning JavaScript ® Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv Chapter 1: Introduction to JavaScript and the Web . . . . . . . . . . . . . . . . . . . . . 1 Chapter 2: Data Types and Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Chapter 3: Decisions, Loops, and Functions . . . . . . . . . . . . . . . . . . . . . . . . . 51 Chapter 4: Common Mistakes, Debugging, and Error Handling . . . . . . . . . . . 87 Chapter 5: JavaScript — An Object-Based Language . . . . . . . . . . . . . . . . . . 133 Chapter 6: Programming the Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 Chapter 7: HTML Forms: Interacting with the User . . . . . . . . . . . . . . . . . . . 219 Chapter 8: Windows and Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 Chapter 9: String Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 Chapter 10: Date, Time, and Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 Chapter 11: Storing Information: Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . 367 Chapter 12: Dynamic HTML and the W3C Document Object Model . . . . . . . 391 Chapter 13: Using ActiveX and Plug-Ins with JavaScript . . . . . . . . . . . . . . . 469 Chapter 14: Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 Chapter 15: JavaScript Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527 Appendix A: Answers to Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591 Appendix B: JavaScript Core Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . 665 Appendix C: W3C DOM Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697 Appendix D: Latin-1 Character Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 25937ffirs.indd i25937ffirs.indd i 9/22/09 11:23:54 AM9/22/09 11:23:54 AM 25937ffirs.indd ii25937ffirs.indd ii 9/22/09 11:23:54 AM9/22/09 11:23:54 AM Beginning JavaScript® Fourth Edition 25937ffirs.indd iii25937ffirs.indd iii 9/22/09 11:23:54 AM9/22/09 11:23:54 AM 25937ffirs.indd iv25937ffirs.indd iv 9/22/09 11:23:54 AM9/22/09 11:23:54 AM Beginning JavaScript® Fourth Edition Paul Wilton Jeremy McPeak 25937ffirs.indd v25937ffirs.indd v 9/22/09 11:23:54 AM9/22/09 11:23:54 AM Beginning JavaScript ® Fourth Edition Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-52593-7 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 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 specifi cally disclaim all warranties, including without limitation warranties of fi tness for a particular purpose. No warranty may be created or extended by sales or pro- motional 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. Library of Congress Control Number: 2009933758 Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affi liates, in the United States and other countries, and may not be used without written permission. JavaScript is a registered trademark of Sun Microsystems Incorporated. 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. 25937ffirs.indd vi25937ffirs.indd vi 9/22/09 11:23:54 AM9/22/09 11:23:54 AM In memory of my mum, June Wilton, who in 2006 lost her brave battle against cancer. She was always very proud of me and my books and showed my books to anyone and everyone she happened to meet however briefl y and whether they wanted to see them or not! She’s very much missed. — Paul Wilton To my family: Starla, Hayden, and Evan (whom we haven’t yet met in person). To my parents: Jerry and Judy. Thank you all for your love and support. — Jeremy McPeak 25937ffirs.indd vii25937ffirs.indd vii 9/22/09 11:23:54 AM9/22/09 11:23:54 AM 25937ffirs.indd viii25937ffirs.indd viii 9/22/09 11:23:54 AM9/22/09 11:23:54 AM [...]... of Professional JavaScript, 2nd Edition (Wiley 2009) and co-author of Professional Ajax, 2nd Edition (Wiley 2007), for getting me into this business — Jeremy McPeak Contents Introduction Chapter 1: Introduction to JavaScript and the Web Introduction to JavaScript What Is JavaScript? JavaScript and the Web Why Choose JavaScript? What Can JavaScript Do for Me? Tools Needed to Create JavaScript Web Applications... To read the FAQs, click the FAQ link on any P2P page xxviii Beginning JavaScript Fourth Edition 1 Introduction to JavaScript and the Web In this introductory chapter, you look at what JavaScript is, what it can do for you, and what you need in order to use it With these foundations in place, you will see throughout the rest of the book how JavaScript can help you to create powerful web applications... programs using JavaScript This process starts in this chapter, by the end of which you will have created your first piece of JavaScript code Introduction to JavaScript In this section you take a brief look at what JavaScript is, where it came from, how it works, and what sorts of useful things you can do with it What Is JavaScript? Having bought this book, you are probably already well aware that JavaScript. .. browser as IE 3 Chapter 1: Introduction to JavaScript and the Web Why Choose JavaScript? JavaScript is not the only scripting language; there are others such as VBScript and Perl So why choose JavaScript over the others? The main reason for choosing JavaScript is its widespread use and availability Both of the most commonly used browsers, IE and Firefox, support JavaScript, as do almost all of the less... inside Adobe Acrobat PDF files to control the display of the page just as in web pages, although Acrobat uses a more limited version of JavaScript However, the question of which scripting language is more powerful and useful has no real answer Pretty much everything that can be done in JavaScript can be done in VBScript, and vice versa What Can JavaScript Do for Me? The most common uses of JavaScript are... to dispel a widespread myth: JavaScript is not the script version of the Java language In fact, although they share the same name, that’s virtually all they do share Particularly good news is that JavaScript is much, much easier to learn and use than Java In fact, languages like JavaScript are the easiest of all languages to learn, but they are still surprisingly powerful JavaScript and the Web For most... technology of the time, Netscape decided that JavaScript sounded more exciting When JavaScript really took off, Microsoft decided to add its own brand of JavaScript, called JScript, to Internet Explorer Since then, Netscape, Microsoft, and others have released improved versions and included them in their latest browsers Although these different brands and versions of JavaScript have much in common, there are... also for how JavaScript interacts with web pages inside a web browser You’ll learn much more about this in later chapters of the book Initially, you’ll look at the essentials of JavaScript before the more advanced stuff In the appendices of this book, you’ll find useful guides to the JavaScript language and how it interacts with the web browser The majority of the web pages containing JavaScript that... Tools Summary Exercise Questions xvi 88 89 90 90 91 91 92 93 93 94 103 104 116 123 127 131 131 Contents Chapter 5: JavaScript — An Object-Based Language 133 Object-Based Programming 133 What Are Objects? Objects in JavaScript Using JavaScript Objects Primitives and Objects 134 134 135 138 JavaScript s Native Object Types String Objects Array Objects New Array Methods The Math Object Number Object The... goes through the JavaScript, it passes it to a special program called an interpreter, which converts the JavaScript to the machine code your computer understands It’s a bit like having a translator translate English to Spanish, for example The important point to note is that the conversion of the JavaScript happens at the time the code is run; it has to be repeated every time this happens JavaScript is . discussion @ p2p.wrox.com 4th Edition Beginning JavaScript ® Paul Wilton, Jeremy McPeak Beginning Wilton, McPeak $39.99 USA $47.99 CAN Web Development /JavaScript JavaScript ® Step-by-step. Introduction to JavaScript and the Web 1 Introduction to JavaScript 1 What Is JavaScript? 1 JavaScript and the Web 2 Why Choose JavaScript? 4 What Can JavaScript Do for Me? 4 Tools Needed to Create JavaScript. 11:23:54 AM Beginning JavaScript Fourth Edition Paul Wilton Jeremy McPeak 25937ffirs.indd v25937ffirs.indd v 9/22/09 11:23:54 AM9/22/09 11:23:54 AM Beginning JavaScript ® Fourth Edition Published

Ngày đăng: 27/06/2014, 05:20

TỪ KHÓA LIÊN QUAN