1. Trang chủ
  2. » Giáo án - Bài giảng

hungry minds javascript examples bible, the essential companion to javascript bible

631 801 0

Đ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 631
Dung lượng 3,86 MB

Nội dung

The essential companion to your JavaScript Bible . . . Even the giant 4th Edition and massive Gold Edition of the JavaScript Bible couldn’t hold all of the superior knowledge and experience of scripting guru Danny Goodman. Examples sections from reference Parts III and IV appeared only on the CD-ROMs of those two books. Now, in this JavaScript Examples Bible, we bring you the Document Object Model (DOM) and core JavaScript language examples sections in their entirety in convenient form — plus new introductory sections by Danny to guide you to the most important concepts and examples in each chapter. Inside, you’ll find ready-to-run examples and step-by-step guides • Interact with DOM and JavaScript core language terminology in real time with Danny’s exclusive workbench: The Evaluator • Experiment with proprietary and industry-standard DOM features in Internet Explorer 5.x and Netscape Navigator 6 • See the latest object-detection coding techniques to accommodate a wide range of browsers today and tomorrow • Learn how to apply language specifics to real application challenges • Gain insight from extensive code listings and Danny’s analysis of coding strategy and design decisions Shelving Category: Web Development/JavaScript Reader Level: Beginning to Advanced System Requirements: PC running Windows 95 or later, Windows NT 4 or later; Power Macintosh running System 7.6 or later. See Appendix A for details and complete system requirements. ISBN 0-7645-4855-7 $29.99 USA $44.99 Canada £24.99 UK incl. VAT JavaScriptExamples Bible Immerse yourself in a JavaScript master’s code examples and analysis Learn JavaScript and DOM behavior via interactive labs Complete your JavaScript Bible library with this invaluable supplement J avaScript Examples Bible Danny Goodman The perfect complement to your 4th or Gold Edition JavaScript Bible ,!7IA7G4-feiffa!:p;M;t;t;T CD-ROM INSIDE! Over 300 Ready-to-Run Example Scripts and More on CD-ROM! www.hungryminds.com 100% ONE HUNDRED PERCENT COMPREHENSIVE AUTHORITATIVE WHAT YOU NEED ONE HUNDRED PERCENT CD-ROM includes: • A searchable e-version of this book • Over 300 ready-to-run scripts from the JavaScript Bible, Gold Edition J avaScript Examples Bible GOODMAN Author of the bestselling JavaScript Bible *85555-AJEEFb The Essential Companion to JavaScriptBible The Essential Companion to JavaScriptBible Hundreds of Example Scripts on CD-ROM! ™ ™ Apply concepts to real applications Experiment in interactive labs 100% COMPREHENSIVE 4855-7 Cover 6/19/01 9:16 AM Page 1 Praise for Danny Goodman’s JavaScript Bible “JavaScript Bible is 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 Bible is 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 4855-7 FM.F 6/26/01 8:33 AM Page i “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 Bible is by far the best JavaScript resource I’ve ever seen (and I’ve seen quite a few).” — Robert J. Mirro, Independent Consultant, RJM Consulting 4855-7 FM.F 6/26/01 8:33 AM Page ii JavaScriptExamples Bible: The Essential Companion to JavaScriptBible 4855-7 FM.F 6/26/01 8:33 AM Page iii 4855-7 FM.F 6/26/01 8:33 AM Page iv JavaScriptExamples Bible: The Essential Companion to JavaScriptBible Danny Goodman Best-Selling Books • Digital Downloads • e-Books • Answer Networks • e-Newsletters • Branded Web Sites • e-Learning Indianapolis, IN ✦ Cleveland, OH ✦ New York, NY 4855-7 FM.F 6/26/01 8:33 AM Page v JavaScriptExamples Bible: The Essential Companion to JavaScriptBible Published by: Hungry Minds, Inc. 909 Third Avenue New York, NY 10022 www.hungryminds.com Copyright © 2001 Danny Goodman. All rights reserved. No part of this book, including interior design, cover design, and icons, may be reproduced or transmitted in any form, by any means (electronic, photocopying, recording, or otherwise) without the prior written permission of the publisher. Library of Congress Control No.: 2001091964 ISBN: 0-7645-4855-7 Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 1B/RY/QX/QR/IN Distributed in the United States by Hungry Minds, Inc. Distributed by CDG Books Canada Inc. for Canada; by Transworld Publishers Limited in the United Kingdom; by IDG Norge Books for Norway; by IDG Sweden Books for Sweden; by IDG Books Australia Publishing Corporation Pty. Ltd. for Australia and New Zealand; by TransQuest Publishers Pte Ltd. for Singapore, Malaysia, Thailand, Indonesia, and Hong Kong; by Gotop Information Inc. for Taiwan; by ICG Muse, Inc. for Japan; by Intersoft for South Africa; by Eyrolles for France; by International Thomson Publishing for Germany, Austria, and Switzerland; by Distribuidora Cuspide for Argentina; by LR International for Brazil; by Galileo Libros for Chile; by Ediciones ZETA S.C.R. Ltda. for Peru; by WS Computer Publishing Corporation, Inc., for the Philippines; by Contemporanea de Ediciones for Venezuela; by Express Computer Distributors for the Caribbean and West Indies; by Micronesia Media Distributor, Inc. for Micronesia; by Chips Computadoras S.A. de C.V. for Mexico; by Editorial Norma de Panama S.A. for Panama; by American Bookshops for Finland. For general information on Hungry Minds’ products and services please contact our Customer Care department; within the U.S. at 800-762-2974, outside the U.S. at 317-572-3993 or fax 317-572-4002. For sales inquiries and resellers information, including discounts, premium and bulk quantity sales and foreign language translations please contact our Customer Care department at 800-434-3422, fax 317-572-4002 or write to Hungry Minds, Inc., Attn: Customer Care department, 10475 Crosspoint Boulevard, Indianapolis, IN 46256. For information on licensing foreign or domestic rights, please contact our Sub-Rights Customer Care department at 212-884-5000. For information on using Hungry Minds’ products and services in the classroom or for ordering examination copies, please contact our Educational Sales department at 800-434-2086 or fax 317-572-4005. For press review copies, author interviews, or other publicity information, please contact our Public Relations department at 317-572-3168 or fax 317-572-4168. For authorization to photocopy items for corporate, personal, or educational use, please contact Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, or fax 978-750-4470. 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. 4855-7 FM.F 6/26/01 8:33 AM Page vi About the Author Danny Goodman is the author of numerous critically acclaimed and bestselling 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 in Netscape’s ViewSource online 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. 4855-7 FM.F 6/26/01 8:33 AM Page vii Credits Acquisitions Editor Sharon Cox Project Editor Neil Romanosky Technical Editor David Wall Copy Editors Jerelind Charles Victoria Lee O’Malley Editorial Manager Colleen Totz Project Coordinator Regina Snyder Graphics and Production Specialists Gabriele McCann Betty Schulte Jeremey Unger Erin Zeltner Quality Control Technicians Laura Albert David Faust Andy Hollandbeck Permissions Editor Laura Moss Media Development Specialist Greg Stephens Media Development Coordinator Marisa Pearman Book Designer Kurt Krames Proofreading and Indexing TECHBOOKS Production Services Cover Illustrator Kate Shaw 4855-7 FM.F 6/26/01 8:33 AM Page viii Preface A common thread running throughout most of my computer-book–writing career is that I tend to write a book I wish I had had in order to learn a new technology in the first place. Because I must write that book without the benefit of existing models, I begin by doing my best to master the technology, and then I write the book to help other newcomers learn as much as I did, but more quickly and with less pain, anguish, and confusion. To accomplish that goal, I write as much content as I feel is necessary to cover the topic in the depth that my readers require. When I started on what became the 4th and Gold editions of the JavaScript Bible, there were models to follow (my previous three editions) plus a substantial amount of brand new material, much of which had not yet been documented anywhere. I also assumed the responsibility of integrating the frequently conflicting and com- peting philosophies of the ways the JavaScript language is applied to a variety of browser brands and versions. Resolving these conflicts is a challenge that I face in my own programming work with clients, and I take great pleasure in sharing my solutions and approaches with other programmers floating in the same boat. As my editor and I began counting the pages I had assembled for these new edi- tions, we discovered that the number of pages far outstripped the printer’s binding capabilities, even in a thicker volume made possible by using a hard cover (the Gold edition). Certainly not all of the words that I had written were so precious that some of them couldn’t be cut. But we were hundreds of pages beyond capacity. To cut that much content would have forced exclusion of coverage of language or doc- ument object model vocabulary. Fortunately, as had been done in previous editions, the plan for the new editions included Adobe Acrobat versions of the books on the accompanying CD-ROM. Although a significant compromise to ease of reading, it was possible to move some of the book’s content to the CD-ROM and leave the most important parts on the printed page. For the softcover 4th edition, reference chapters covering less-used or advanced subjects were pulled from print; for the hardcover Gold edition, which was longer and targeted more for professional scripters, the advanced chapters were put back into the book (along with 15 additional chapters for that edition), and the JavaScript tutorial was exiled to the CD-ROM. But even after making the difficult decisions about which chapters could go to the CD-ROMs, the page counts for both volumes were still excessive. Something else — something big — had to go. The remaining bundle that could free us from the page 4855-7 FM.F 6/26/01 8:33 AM Page ix [...]... To assist in the vertical positioning of the logo, the offsetTop property of the DIV object provides the position of the start of the DIV with respect to its outer container (the BODY) Unfortunately, IE/Mac uses the clientTop property to obtain the desired dimension That measure (assigned to the paragraphTop variable), plus the clientHeight of the DIV, provides the top coordinate of the image... elementObject.canHaveChildren 4855-7 ch01.F 8 6/26/01 8:34 AM Page 8 JavaScript Examples Bible: The Essential Companion to JavaScript Bible canHaveHTML NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5  Compatibility Example Use The Evaluator (Chapter 13 in the JavaScript Bible) to experiment with the canHaveHTML property Enter the following statements into the top text field and observe the results:... sections The new volume would act as a companion to both the 4th and Gold editions of the JavaScript Bible Using Appendix F as a starting point, I divided the content into chapters along the same lines as the JavaScript Bible reference sections This also gave me a chance to study the examples for each chapter with fresh eyes The examples haven’t changed, but I had the opportunity to direct the reader’s... Many examples throughout this book refer to The Evaluator This Web page application is described at length in Chapter 13 of the big books You can find the file for The Evaluator within the Listings\Chap13 folder on the CD-ROM for either the big book or this book CD-ROM The accompanying CD-ROM contains the complete set of over 300 ready -to- run HTML documents from the JavaScript Bible, Gold Edition These... following statement into the topmost text box: document.all[8].tagName attributes NN2 Compatibility NN3 NN4 NN6 IE3/J1 IE3/J2 IE4  IE5 IE5.5   Example Use The Evaluator (Chapter 13 in the JavaScript Bible) to examine the values of the attributes array for some of the elements in that document Enter each of the following expressions into the lower text field, and see the array contents in the Results textarea... x JavaScript Example Bible: The Essential Companion to JavaScript Bible count devil was all of the Example sections from the reference vocabulary By being nondiscriminatory about these extractions — that is, extracting all of them instead of only selected sections — we could convey to readers a consistent organizational model In the end, the extracted Example sections from Parts III and IV found their... volume was created as part of the JavaScript Bible, the acknowledgments that you see in your copy of the 4th or Gold editions apply equally to this volume But this JavaScript Examples Bible did not come into being without additional effort on the part of dedicated Hungry Minds, Inc., staff In particular, I want to thank Sharon Cox for turning my idea into a title, and editor Neil Romanosky, who, even... page, the toggleEdit() function captures the opposite of the current editable state via the isContentEditable property of the DIV that is subject to edit You switch on editing for that element in the next statement by assigning the new value to the contentEditable property of the DIV For added impact, turn the text of the DIV to red to provide additional user feedback about what is editable on the page... code does when the page is loaded into a browser Now you know the story behind the JavaScript Examples Bible Some budgetconscious readers may not be thrilled to pay more for what appears to be a printout of content they already own in electronic format If so, then please continue using the Acrobat version But if, like me, you enjoy the portability and visual scanability of a printed work, then keeping... Example The style of an element toggles between “on” and “off” in Listing 15-5 by virtue of setting the element’s className property alternatively to an existing style sheet class selector name and an empty string When you set the className to an empty string, the default behavior of the H1 element governs the display of the first header A click of the button forces the style sheet rule to override the . from the JavaScript Bible, Gold Edition J avaScript Examples Bible GOODMAN Author of the bestselling JavaScript Bible *85555-AJEEFb The Essential Companion to JavaScript ™ Bible The Essential Companion. Page ii JavaScript ™ Examples Bible: The Essential Companion to JavaScript ™ Bible 4855-7 FM.F 6/26/01 8:33 AM Page iii 4855-7 FM.F 6/26/01 8:33 AM Page iv JavaScript ™ Examples Bible: The Essential Companion. 6/26/01 8:33 AM Page v JavaScript ™ Examples Bible: The Essential Companion to JavaScript ™ Bible Published by: Hungry Minds, Inc. 909 Third Avenue New York, NY 10022 www.hungryminds.com Copyright

Ngày đăng: 28/04/2014, 16:50

TỪ KHÓA LIÊN QUAN