ebook img

JavaScript Tutorial PDF

2177 Pages·2001·34.64 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview JavaScript Tutorial

Turn in: .75 Board: 7.0625 .4375 VISIBLE SPINE = 2.375 .4375 Board: 7.0625 Turn in: .75 The Ultimate Guide to JavaScript for Professionals G O L D G O L D E D I T I O N E D I T I O N “I highly recommend Danny Goodman’s Featuring 15 bonus chapters with expanded coverage of data validation, debugging, plug-ins, security, and more, Advance your JavaScript plus nine chapters on ready-to-use applications, this monumental reference is truly the most comprehensive and JJ JavaScript Bible.” skills with the most —Brendan Eich, creator of JavaScript useful guide to JavaScript available today. Writing with his trademark clarity and verve, leading JavaScript aa comprehensive resource authority Danny Goodman covers everything from Cascading Style Sheets and Document Object Models to available XML data — and gives you all the tools you need to harness the full power of client-side JavaScript. vv Conquer high-end Encyclopedic coverage of “I continue to use the book [JavaScript Bible] on a daily basis and would be lost without it.” scripting challenges using JavaScript and DOMs —Mike Warner, Founder, Oak Place Publications aa the latest techniques • Master JavaScript and DOM concepts with Danny’s “Whether you are a professional or a beginner, Optimize scripts for exclusive interactive workbench: The Evaluator this is a great book to get.” Internet Explorer 5.5 SS • Learn state-of-the-art debugging and tracing tricks —Brant Mutch, Web Application Developer, Wells Fargo Card Services, Inc. and Netscape Navigator6 • Apply the latest JavaScript 1.5 exception handling and custom object techniques cc • Implement cross-browser Dynamic HTML applications for MSIE 5.5 and Navigator 6 Turn plain rr Features 15 The Definitive pages into bonus chapters • Embed a universal sound plug-in controller in your interactive JavaScript Guide pages applications ii — Over 175,000 Copies in Print • Develop deployment strategies that best suit pp JJ SS your content goals and target audience aavvaa ccrriipptt tt ®® CD-ROM includes: ®® •A searchable e-version of the book •Nearly 300 ready-to-run scripts from the book •Printable version of the JavaScript and Browser GOODMAN Object Quick Reference •Plusthe full version of WebSpice Objects, a Bible demo of BBEdit, and TextPad shareware w w w. h u n g r y m i n d s . c o m Bible System Requirements: $ 69.99USA Reader Level: Shelving Category: PC running Windows 95 or later, Windows $104.99Canada Beginning to Advanced Web Development/JavaScript NT 4 or later; Power Macintosh running £ 55.99UK incl. VAT Hundreds of Example System 7.6 or later. See Appendix E for Scripts on CD-ROM! details and complete system requirements. ISBN 0-7645-4718-6 *85555-ADAGGe ,!7IA7G4-fehbii!:p;Q;T;t;t CD-ROM INSIDE! Nearly 300 Ready-to-Run Danny Goodman Example Scripts and More JavaScript pioneer and Consultant on CD-ROM! With a foreword by Brendan Eich, creator of JavaScript Praise for Danny Goodman’s JavaScript Bible “JavaScript Bibleis the definitive resource in JavaScript programming. I am never more than three feet from my copy.” —Steve Reich, CEO, PageCoders “This book is a must-have for any Web developer or programmer.” —Thoma Lile, President, Kanis Technologies, Inc. “Outstanding book. I would recommend this book to anyone interested in learning to develop advanced Web sites. Mr. Goodman did an excellent job of organizing this book and writing it so that even a beginning programmer can understand it.” —Jason Hensley, Director of Internet Services, NetVoice, Inc. “Goodman is always great at delivering clear and concise technical books!” —Dwayne King, Chief Technology Officer, White Horse “JavaScript Bibleis well worth the money spent!” —Yen C.Y. Leong, IT Director, Moo Mooltimedia, a member of SmartTransact Group “A must-have book for any Internet developer.” —Uri Fremder, Senior Consultant, TopTier Software “I love this book! I use it all the time, and it always delivers. It’s the only JavaScript book I use!” —Jason Badger, Web Developer “Whether you are a professional or a beginner, this is a great book to get.” —Brant Mutch, Web Application Developer, Wells Fargo Card Services, Inc. “I never thought I’d ever teach programming before reading your book [JavaScript Bible]. It’s so simple to use—the Programming Fundamentals section brought it all back! Thank you for such a wonderful book, and for breaking through my program- ming block!” —Susan Sann Mahon, Certified Lotus Instructor, TechNet Training “I continue to get so much benefit from JavaScript Bible. What an amazing book! Danny Goodman is the greatest!” —Patrick Moss “Danny Goodman is very good at leading the reader into the subject. JavaScript Bible has everything we could possibly need.” —Philip Gurdon “An excellent book that builds solidly from whatever level the reader is at. A book that is both witty and educational.” —Dave Vane “I continue to use the book on a daily basis and would be lost without it.” —Mike Warner, Founder, Oak Place Productions “JavaScript Bibleis by farthe best JavaScript resource I’ve ever seen (and I’ve seen quite a few).” —Robert J. Mirro, Independent Consultant, RJM Consulting JavaScript® Bible, Gold Edition JavaScript® Bible, Gold Edition Danny Goodman With a foreword by Brendan Eich, creator of JavaScript Best-Selling Books • Digital Downloads • e-Books • Answer Networks • e-Newsletters • Branded Web Sites • e-Learning Indianapolis, IN ✦Cleveland, OH ✦New York, NY JavaScript®Bible, Gold Edition Contemporanea de Ediciones for Venezuela; by Published by Express Computer Distributors for the Caribbean and Hungry Minds, Inc. West Indies; by Micronesia Media Distributor, Inc. for 909 Third Avenue Micronesia; by Chips Computadoras S.A. de C.V. for New York, NY 10022 Mexico; by Editorial Norma de Panama S.A. for www.hungryminds.com Panama; by American Bookshops for Finland. Copyright © 2001 Danny Goodman. All rights For general information on Hungry Minds’ products reserved. No part of this book, including interior and services please contact our Customer Care design, cover design, and icons, may be reproduced department; within the U.S. at 800-762-2974, outside or transmitted in any form, by any means (electronic, the U.S. at 317-572-3993 or fax 317-572-4002. photocopying, recording, or otherwise) without the For sales inquiries and resellers information, prior written permission of the publisher. including discounts, premium and bulk quantity sales Library of Congress Control Number: 2001090713 and foreign language translations please contact our Customer Care department at 800-434-3422, fax ISBN: 0-7645-4718-6 317-572-4002 or write to Hungry Minds, Inc., Attn: Printed in the United States of America Customer Care department, 10475 Crosspoint 10 9 8 7 6 5 4 3 2 1 Boulevard, Indianapolis, IN 46256. 1P/RV/QW/QR/IN For information on licensing foreign or domestic Distributed in the United States by Hungry Minds, Inc. rights, please contact our Sub-Rights Customer Care department at 212-884-5000. Distributed by CDG Books Canada Inc. for Canada; by Transworld Publishers Limited in the United For information on using Hungry Minds’ products Kingdom; by IDG Norge Books for Norway; by IDG and services in the classroom or for ordering Sweden Books for Sweden; by IDG Books Australia examination copies, please contact our Educational Publishing Corporation Pty. Ltd. for Australia and Sales department at 800-434-2086 or fax 317-572-4005. New Zealand; by TransQuest Publishers Pte Ltd. for For press review copies, author interviews, or other Singapore, Malaysia, Thailand, Indonesia, and Hong publicity information, please contact our Public Kong; by Gotop Information Inc. for Taiwan; by ICG Relations department at 317-572-3168 or fax Muse, Inc. for Japan; by Intersoft for South Africa; by 317-572-4168. Eyrolles for France; by International Thomson For authorization to photocopy items for corporate, Publishing for Germany, Austria, and Switzerland; by personal, or educational use, please contact Distribuidora Cuspide for Argentina; by LR Copyright Clearance Center, 222 Rosewood Drive, International for Brazil; by Galileo Libros for Chile; by Danvers, MA 01923, or fax 978-750-4470. Ediciones ZETA S.C.R. Ltda. for Peru; by WS Computer Publishing Corporation, Inc., for the Philippines; by LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK. THE PUBLISHER AND AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. THERE ARE NO WARRANTIES WHICH EXTEND BEYOND THE DESCRIPTIONS CONTAINED IN THIS PARAGRAPH. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS. THE ACCURACY AND COMPLETENESS OF THE INFORMATION PROVIDED HEREIN AND THE OPINIONS STATED HEREIN ARE NOT GUARANTEED OR WARRANTED TO PRODUCE ANY PARTICULAR RESULTS, AND THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY INDIVIDUAL. NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES. Trademarks:JavaScript is a registered trademark or trademark of Sun Microsystems, Inc. All other trademarks are property of their respective owners. Hungry Minds, Inc. is not associated with any product or vendor mentioned in this book. is a trademark of Hungry Minds, Inc. About the Author Danny Goodmanis the author of numerous critically acclaimed and best-selling books, including The Complete HyperCard Handbook, Danny Goodman’s AppleScript Handbook, and Dynamic HTML: The Definitive Reference. He is a renowned authority and expert teacher of computer scripting languages and is widely known for his “JavaScript Apostle” articles at Netscape’s ViewSourceonline developer newsletter. His writing style and pedagogy continue to earn praise from readers and teachers around the world. To help keep his finger on the pulse of real-world programming challenges, Goodman frequently lends his touch as consulting programmer and designer to leading-edge World Wide Web and intranet sites from his home base in the San Francisco area. Credits Acquisitions Editor Quality Control Technicians Debra Williams Cauley Laura Albert Joel Draper Project Editor Andy Hollandbeck Neil Romanosky Susan Moritz Technical Editor Permissions Editor David Wall Laura Moss Copy Editors Media Development Specialist Jerelind Charles Greg Stephens Victoria Lee O’Malley Media Development Coordinator Proof Editor Marisa Pearman Cordelia Heaney Book Designer Editorial Manager Kurt Krames Colleen Totz Proofreading Project Coordinators TECHBOOKS Production Services Cindy Phipps Regina Snyder Indexer Johnna VanHoose Dinse Graphics and Production Specialists Sean Decker Cover Illustrator John Greenough Kate Shaw LeAndra Johnson Stephanie Johnson Gabriele McCann Jill Piscitelli Heather Pope Ron Terry Erin Zeltner Foreword A s JavaScript’s creator, I would like to say a few words about where JavaScript has been, where it is going, and how the book you’re holding will help you to make the most of the language. JavaScript was born out of a desire to let HTML authors write scripts directly in their documents. This may seem obvious now, but in the spring of 1995 it was novel and more than a little at odds with both the conventional wisdom (that HTML should describe static document structure only) and the Next Big Thing (Java applets, which were hyped as the one true way to enliven and extend Web pages). Once I got past these contentions, JavaScript quickly shaped up along the following lines: ✦ “Java-lite” syntax.Although the “natural language” syntax of HyperTalk was fresh in my mind after a friend lent me The Complete HyperCard Handbookby some fellow named Goodman, the Next Big Thing weighed heavier, especially in light of another goal: scripting Java applets. If the scripting language resembled Java, then those pro- grammers who made the jump from JavaScript to Java would welcome similarities in syntax. But insisting on Java’s class and type declarations, or on a semicolon after each statement when a line ending would do, was out of the question—scripting for most people is about writing short snippets of code, quickly and without fuss. ✦ Events for HTML elements.Buttons should have onClickevent handlers. Documents load and unload from windows, so windows should have onLoad and onUnload handlers. Users and scripts submit forms: thus the onSubmit handler. Although not initially as flexible as HyperCard’s messages (whose handlers inspired the onEvent naming convention), JavaScript events let HTML authors take control of user interaction from remote servers and respond quickly to user gestures and browser actions. With the adoption of the W3C DOM Level 2 event handling recom- mendations, JavaScript in modern browsers has fully flexible control over events. ✦ Objects without classes.The Self programming language proved the notion of prototype-based inheritance. For JavaScript, I wanted a single prototype per object (for simplicity and efficiency), based by default on the function called using the new operator (for consonance with Java). To avoid distinguishing constructors from methods from functions, all functions receive the object naming them as the prop- erty that was called, in the thisparameter. Although prototypes didn’t appear until Navigator 3, they were prefigured in Version 2 by quoted text being treated as an object (the String object prototype, to which users could attach methods). ✦ Generated HTML.Embedding JavaScript in HTML gave rise to a thought: Let the script speak HTML, as if the emitted text and markup were loaded in place of the script itself. The possibilities went beyond automating current or last-modified dates, to computing whole trees of tables where all the repeated structure was rolled up in a scripted loop, while the varying contents to be tabulated came in min- imal fashion from JavaScript objects forming a catalog or mini-database.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.