DOM scripting web design with JavaScript and the Document Object Model. - Description based on print version record. - Includes index
معرفی کتاب «طراحی وب با DOM اسکریپتینگ و جاوااسکریپت و مدل شیء سند. - توصیف بر اساس نسخه چاپی. - شامل فهرست» (با عنوان لاتین DOM scripting web design with JavaScript and the Document Object Model. - Description based on print version record. - Includes index) نوشتهٔ Jeremy Keith, Jeffrey Sambells (auth.)، منتشرشده توسط نشر Apress L. P. در سال 2010. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.
In this Second Edition of the popular DOM Scripting: Web Design with JavaScript and the Document Object Model, comes a modern revision to include current best practices and guidelines. There is also full coverage of HTML5 in a new, dedicated chapter, and details on JavaScript libraries and how they can help your scripting. The book gives you everything you need to start using JavaScript and the Document Object Model to enhance your web pages with client-side dynamic effects and user-controlled animation. It shows you how JavaScript, HTML5, and Cascading Style Sheets (CSS) work together to create usable, standards-compliant web designs. We'll also cover cross-browser compatibility with your DOM scripts and how to make sure they degrade gracefully when JavaScript isn't available. DOM Scripting: Web Design with JavaScript and the Document Object Model focuses on JavaScript for adding dynamic effects and manipulating page structure on the fly using the Document Object Model. You'll start off by receiving a crash course in JavaScript and the DOM, then move on to several real-world examples that you'll build from scratch, including dynamic image galleries and dynamic menus. You'll also learn how to manipulate web page styles using the CSS DOM, and create mark-up on the fly. This book is perfect for your needs if you want to create websites that are beautiful, dynamic, accessible - and standards compliant! What you’ll learn Apply dynamic behavior to your pages without inserting JavaScript in your markup. Write scripts that degrade gracefully when JavaScript isn’t available. Use web standards to ensure cross-browser compatibility. Harness the power of the DOM to create user-controlled animation. Also includes an introduction to Ajax. Who this book is for This book is for web developers wanting to expand their knowledge of the DOM to add interactivity and functionality to their web pages. Table of Contents A Brief History of JavaScript JavaScript Syntax The Document Object Model A JavaScript Image Gallery Best Practices The Image Gallery Revisited Creating Markup on the Fly Enhancing Content CSS-DOM An Animated Slideshow HTML5 Putting It All Together DOM Scripting Libraries Title Page 1 Copyright Page 2 Contents at a Glance 4 Table of Contents 5 About the Authors 13 About the Technical Reviewer 14 Acknowledgments 15 Introduction 16 CHAPTER 1 A Brief History of JavaScript 17 The origins of JavaScript 17 The Document Object Model 18 The browser wars 19 The D word: DHTML 19 Clash of the browsers 19 Raising the standard 20 Thinking outside the browser 20 The end of the browser wars 20 A new beginning 21 What’s next? 21 CHAPTER 2 JavaScript Syntax 23 What you’ll need 23 Syntax 25 Statements 25 Comments 26 Variables 26 Data types 28 Numbers 30 Boolean values 30 Arrays 30 Associative arrays 32 Objects 32 Operations 33 Arithmetic operators 33 Conditional statements 35 Comparison operators 36 Logical operators 37 Looping statements 38 The while loop 38 The do...while loop 39 The for loop 40 Functions 40 Variable scope 42 Objects 43 Native objects 44 Host objects 45 What’s next? 45 CHAPTER 3 The Document Object Model 46 D is for document 46 Objects of desire 46 Dial M for model 47 Nodes 48 Element nodes 49 Text nodes 49 Attribute nodes 49 Cascading Style Sheets 50 The class attribute 51 The id attribute 51 Getting Elements 52 getElementById 52 getElementsByTagName 53 getElementsByClassName 54 Taking stock 56 Getting and Setting Attributes 56 getAttribute 56 setAttribute 58 What’s next? 59 CHAPTER 4 A JavaScript Image Gallery 60 The markup 60 The JavaScript 62 A DOM diversion 63 Finishing the function 64 Applying the JavaScript 64 Event handlers 64 Expanding the function 66 Introducing childNodes 66 Introducing the nodeType property 67 Adding a description in the markup 68 Changing the description with JavaScript 69 Introducing the nodeValue property 69 Introducing firstChild and lastChild 70 Using nodeValue to update the description 70 What’s next? 73 CHAPTER 5 Best Practices 74 Mistakes of the past 74 Don’t blame the messenger 74 The Flash mob 75 Question everything 75 Graceful degradation 76 The pseudo-protocol 77 Inline event handlers 77 Who cares? 78 The lessons of CSS 78 Separation of structure and style 78 Progressive enhancement 79 Unobtrusive JavaScript 80 Backward compatibility 82 Object detection 82 Browser sniffing 83 Performance considerations 84 Minimizing DOM access and markup 84 Assembling and placing scripts 85 Minification 85 What’s next? 86 CHAPTER 6 The Image Gallery Revisited 87 A quick recap 87 Does it degrade gracefully? 88 Is the JavaScript unobtrusive? 89 Adding the event handler 89 Checkpoints 90 What’s in a name? 92 Changing behavior 93 Closing it up 94 Share the load 94 Assuming too much 96 Fine-tuning 98 Keyboard access 100 Beware of onkeypress 101 Sharing hooks with CSS 102 DOM Core and HTML-DOM 105 What’s next? 106 CHAPTER 7 Creating Markup on the Fly 108 Some old-school methods 108 document.write 108 innerHTML 110 DOM methods 113 createElement 114 appendChild 115 createTextNode 116 A more complex combination 118 Revisiting the image gallery 120 Inserting a new element before an existing one 122 Inserting a new element after an existing one 123 Writing the insertAfter function 123 Using the insertAfter function 124 The finished image gallery 125 Ajax 129 The XMLHttpRequest object 129 Progressive enhancement with Ajax 134 Hijax 134 What’s next? 135 CHAPTER 8 Enhancing Content 136 What not to do 136 Making the invisible visible 137 The content 137 The markup: HTML, XHTML, or HTML5 138 The CSS 140 The JavaScript 141 Displaying abbreviations 141 Writing the displayAbbreviations function 142 Creating the markup 144 Inserting the definition list 145 Checking for compatibility 147 The final markup 148 A browser bomb 149 Displaying citations 152 Writing the displayCitations function 153 Finding your element 153 Creating the link 155 Inserting the link 155 Improving the script 156 The final markup 157 Displaying access keys 158 Retrieving and attaching information 161 What’s next? 161 CHAPTER 9 CSS-DOM 162 Three sheets to the Web 162 Structure 162 Presentation 163 Behavior 163 Separation 164 The style property 165 Getting styles 166 Inline only 170 Setting styles 171 Knowing when to use DOM styling 173 Styling elements in the node tree 173 Repetitive styling 177 Responding to events 181 className 183 Abstracting a function 186 What’s next? 187 CHAPTER 10 An Animated Slideshow 188 Animation basics 188 Position 188 Time 191 Incremental movement 191 Abstraction 194 Creating the moveElement function 195 Using the moveElement function 197 Practical animation 200 The situation 201 The solution 202 CSS 203 JavaScript 205 A question of scope 208 Refining the animation 210 Adding a safety check 213 Generating markup 214 What’s next? 217 CHAPTER 11 HTML5 218 What is HTML5? 218 A little help from a friend 219 A few examples 221 Canvas 221 Audio/Video 226 The Return of Tag Soup 227 Customizing Controls 229 Forms 234 Is there anything else? 238 What's Next 239 CHAPTER 12 Putting It All Together 240 The brief 240 Raw materials 240 Site structure 240 Page structure 242 Design 242 CSS 243 Color 245 Layout 247 Typography 249 Markup 251 JavaScript 251 Page highlighting 253 JavaScript slideshow 256 Internal navigation 261 JavaScript image gallery 265 Table enhancements 269 Form enhancements 274 Labels 276 Placeholder values 277 Form validation 280 Form submission 284 Minification 289 What’s next? 290 APPENDIX DOM Scripting Libraries 291 Choosing a library 292 A few libraries 293 Content delivery networks 294 Syntax 295 Selecting elements 296 CSS selectors 296 Library-specific selectors 298 Filtering with a callback 300 Manipulating the DOM document 301 Creating content 301 Manipulating content 303 Handling events 303 Load events 303 Other events 304 Ajax 305 Ajax with Prototype 305 Ajax with jQuery 308 Animation and effects 310 CSS property-based animations 311 Packaged animations 312 Remember accessibility 313 Summary 313 Index 314
With this second edition of the popular DOM Scripting: Web Design with JavaScript and the Document Object Model comes a modern revision to update best practices and guidelines. It includes full coverage of HTML5 in a new, dedicated chapter, and details on JavaScript libraries and how they can help your scripting.
The book provides everything you'll need to start using JavaScript and the Document Object Model to enhance your web pages with client-side dynamic effects and user-controlled animation. It shows how JavaScript, HTML5, and Cascading Style Sheets (CSS) work together to create usable, standards-compliant web designs. We'll also cover cross-browser compatibility with DOM scripts and how to make sure they degrade gracefully when JavaScript isn't available.
DOM Scripting: Web Design with JavaScript and the Document Object Model focuses on JavaScript for adding dynamic effects and manipulating page structure on the fly using the Document Object Model. You'll start with a crash course in JavaScript and the DOM, then move on to several real-world examples that you'll build from scratch, including dynamic image galleries and dynamic menus. You'll also learn how to manipulate web page styles using the CSS DOM, and create markup on the fly.
If you want to create websites that are beautiful, dynamic, accessible, and standards-compliant, this is the book for you!
What you’ll learn
- Apply dynamic behavior to your pages without inserting JavaScript in your markup
- Write scripts that degrade gracefully when JavaScript isn’t available
- Use web standards to ensure cross-browser compatibility
- Harness the power of the DOM to create user-controlled animation
- Also includes an introduction to Ajax
Who this book is for This book is for web developers wanting to expand their knowledge of the DOM to add interactivity and functionality to their web pages.
Table of Contents
- A Brief History of JavaScript
- JavaScript Syntax
- The Document Object Model
- A JavaScript Image Gallery
- Best Practices
- The Image Gallery Revisited
- Creating Markup on the Fly
- Enhancing Content
- CSS-DOM
- An Animated Slideshow
- HTML5
- Putting It All Together
- DOM Scripting Libraries
Front Matter....Pages i-xvi A Brief History of JavaScript....Pages 1-6 JavaScript Syntax....Pages 7-29 The Document Object Model....Pages 31-44 A JavaScript Image Gallery....Pages 45-58 Best Practices....Pages 59-71 The Image Gallery Revisited....Pages 73-93 Creating Markup on the Fly....Pages 95-122 Enhancing Content....Pages 123-148 CSS-DOM....Pages 149-174 An Animated Slideshow....Pages 175-204 HTML5....Pages 205-226 Putting It All Together....Pages 227-277 Back Matter....Pages 279-314