Pro JavaScript Techniques

所需积分/C币:6 2017-08-20 10:01:50 5.66MB PDF
5
收藏 收藏
举报

Pro JavaScript Techniques Apress
7273fmfinal qxd 11/16/06 8: 02 AM Page ii Pro JavaScriptTM Techniques Copyright o 2006 by John Resig All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher ISBN-13(pbk):978-1-59059-727-9 ISBN-10(pbk):1-59059-727-3 Printed and bound in the united states of america 987654321 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc, in the US and other countries. Apress, Inc, is not affiliated with Sun Microsystems, Inc, and this book was writ ten without endorsement from Sun Microsystems, Inc Lead editor Chris mills Technical reviewer. Dan Webb Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft, Jim Sumser Keir Thomas, Matt Wade Project Manager: Tracy Brown Collins Copy Edit m Nicole flo Copy Editor: Jennifer Whipple Assistant Production Director: Kari Brooks-Copony Production editor: laura esterman Compositor: Linda Weidemann, Wolf Creek Press Proofreader: April eddy Indexer: Broccoli Information Management Artist: April Milne Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, InC, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm com orvisithttp://www.springeronline.com For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, Ca94710.Phone510-549-5930,fax510-549-5939,e-mailinfo@apress.comorvisithttp://www.apress.com The information in this book is distributed on an"as is"basis, without warranty. Although every pre caution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work Thesourcecodeforthisbookisavailabletoreadersathttp://www.apress.comintheSourceCode/ Downloadsectionandonthebookswebsiteathttp://jspro.org 7273fmfinal qxd 11/16/068: 02 AM Page iii Contents at a glance About the author About the technical reviewer ,,ⅩVl Acknowledgments XIX PART 1 Introducing Modern JavaScript CHAPTER 1 Modern JavaScript Programming 3 PART 2 Professional JavaScript Development CHAPTER 2 object-Oriented JavaScript.................19 CHAPTER 3 Creating Reusable Code 39 CHAPTER 4 Tools for Debugging and Testing...............59 ParT 3 Unobtrusive JavaScript CHAPTER 5 The document object Model ..77 CHAPTER 6 Events .111 CHAPTER 7 JavaScript and css 135 CHAPTER 8 Improving Forms CHAPTER 9 Building an Image Gallery PART4■Aax CHAPTER 10 Introduction to Ajax 215 CHAPTER 11 Enhancing Blogs with Ajax..................233 CHAPTER 12 Autocomplete Search 247 CHAPTER 13 An Ajax Wiki 7273fmfinal qxd 11/16/06 8: 02 AM Page iv PART 5 The Future of JavaScript CHAPTER 14 Where Is JavaScript Going? 287 PART6■■ Appendixes APPENDIX A DOM Reference APPENDIX B Events reference ..,...325 APPENDIX C The browsers ...,....,,,,,,,,,,,,,,,,,,...345 INDEX ....349 7273fmfinal qxd 11/16/068: 02 AM Page v Contents About the author About the technical reviewer ,,ⅩVl Acknowledgments XIX PART 1 Introducing Modern JavaScript CHAPTER 1 Modern JavaScript Programming Object-Oriented JavaScript Testing your code Packaging for Distribution Unobtrusive dOM Scripting 7 The document object Model 8 Events JavaScript and css 10 Ajax 10 Browser Support 13 ummary. ParT 2 Professional JavaScript Development CHAPTER 2 Object-Oriented JavaScript 19 Language Features References 19 Function Overloading and Type-Checking Scope 25 Closures 27 Context 7273fmfinal qxd 11/167068: 02 AM Page vi CONTENTS Object-Oriented Basics Objects 32 Obiect Creation ummary CHAPTER 3 Creating reusable code Standardizing object-Oriented Code...............39 Prototypal Inheritance Classical Inheritance 40 The Base Library The Prototype Library Packaging 49 Namespacing 49 Cleaning Up your code 52 Compression 54 Distribution Summary 58 CHAPTER 4 Tools for Debugging and Testing 59 Debugging Error console DOM Inspectors 64 Firebug 67 Venkman Testing sUnit JuNit 71 Test. Simple 72 Summary 73 7273fmfinal qxd 11/16/06 8: 02 AM Page vii CONTENTS PART 3 Unobtrusive JavaScript CHAPTER 5 The Document Object Model An Introduction to the document object model Navigating the DOM Handling White Space in the DOM Simple DOM Navigation 82 Binding to Every HTML Element ...84 Standard dOM Methods Waiting for the html dom to load 87 Waiting for the Page to 87 Waiting for Most of the doM to Load 87 Figuring out When the doM is Loaded Finding Elements in an HTML Document Finding Elements by Class Name Finding Elements by CSS Selector..............92 XPath Getting the Contents of an Element Getting the Text Inside an Element Getting the hTML Inside an Element Working with Element Attributes Getting and Setting an attribute value 99 Modifying the dOM .103 Creating Nodes Using the DOM 103 Inserting into the dOM...................104 Injecting HTML into the DOM 105 Removing Nodes from the DOM Summary 110 CHAPTER 6 Events ...,.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,111 Introduction to JavaScript Events ..111 Asynchronous Events VS. Threads .111 Event Phases ..114 Common event features The Event object 116 The this Keyword 117 Canceling Event Bubbling .118 Overriding the browser's Default Action 119 7273fmfinal qxd 11/16/06 8: 02 AM Page viii CONTENTS Binding event listeners 122 Traditional binding 122 DOM Binding: W3C 124 DOM Binding: IE ..125 add Event and remove Event 126 Types of Events 129 Unobtrusive DOM Scripting .129 Anticipating JavaScript Being Disabled 130 Making Sure Links Don't Rely on JavaScript ...130 Watching for When CSs is Disabled 131 Event Accessibility Summary 133 CHAPTER 7 JavaScript and cSS ...135 Accessing Style Information .135 Dynamic Elements 137 An element's position ...137 An elements size .....147 An Element's visibility 149 Animations 151 Slide n 152 Fade In 152 The browser .153 Mouse position ......153 The viewport Drag-and-Drop 157 Libraries .163 moo. fx and jQuery 163 Scriptaculous .164 Summary.… .167 CHAPTER 8 Improving Forms 169 Form validation Required Fields 172 Pattern Match 174 Rule se 7273fmfinal qxd 11/16/06 8: 02 AM Page ix CONTENTS Displaying error messages .....179 Validation ...179 When to validate .....∴...183 Usability Improvements ..186 Hover labels Marking Required Fields..................188 Summary.…. .189 ChaPTER 9 Building an Image Gallery ..191 EXample galleries ....191 Lightbox 191 Thick Box Building the gallery Loading Unobtrusively 198 Transparent Overlay .......200 Positioned box 203 Navigation ...207 Slideshow 209 Summary 212 PART 4 Ajax CHAPTER 10 Introduction to Ajax 215 Using Ajax 215 Http Requests 216 Http Response 221 Handling Response Data 225 The Complete Ajax Package 226 EXamples of Different Data Usage ..229 An XML-Based RSs Feed 229 An HTML Injector 廉着面 廉着面 .231 jSoN and JavaScript: Remote Execution 232 Summary 232

...展开详情
试读 127P Pro JavaScript Techniques
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
上传资源赚钱or赚积分
最新推荐
Pro JavaScript Techniques 6积分/C币 立即下载
1/127
Pro JavaScript Techniques第1页
Pro JavaScript Techniques第2页
Pro JavaScript Techniques第3页
Pro JavaScript Techniques第4页
Pro JavaScript Techniques第5页
Pro JavaScript Techniques第6页
Pro JavaScript Techniques第7页
Pro JavaScript Techniques第8页
Pro JavaScript Techniques第9页
Pro JavaScript Techniques第10页
Pro JavaScript Techniques第11页
Pro JavaScript Techniques第12页
Pro JavaScript Techniques第13页
Pro JavaScript Techniques第14页
Pro JavaScript Techniques第15页
Pro JavaScript Techniques第16页
Pro JavaScript Techniques第17页
Pro JavaScript Techniques第18页
Pro JavaScript Techniques第19页
Pro JavaScript Techniques第20页

试读结束, 可继续阅读

6积分/C币 立即下载 >