[...]... Table of Contents | xi Preface I wrote my first book on JavaScript 15 years ago, and had to scramble just to find enough material to fill a book With the JavaScript Cookbook, I had to choose among hundreds of uses to determine what to include After all these years of watching JavaScript grow, I am still surprised at how far-reaching the use of JavaScript has become In my opinion, there is no more useful... desktop file directly in client-side JavaScript It’s not a complete encyclopedia of JavaScript use today—no one book can cover all there is to cover But hopefully, you’ll come away with an appreciation of all you can do with JavaScript Bon appetit! Audience, Assumptions, and Approach Readers of this book should have some exposure to web development, and the use of JavaScript In addition, the recipe format... first focuses on existing JavaScript functionality and objects; the second focuses more on JavaScript used within environments, such as a browser If you’re relatively new to JavaScript, I recommend working through all of the recipes in the first 10 chapters before tackling the recipes later in the book Following is a chapter breakdown of the book: Chapter 1, Working with JavaScript Strings Covers some... ECMAScript 5, the tools, the APIs, the libraries, the browsers, and all the other fun stuff that helps make JavaScript development as exciting today as it was 15 years ago xxii | Preface CHAPTER 1 Working with JavaScript Strings 1.0 Introduction JavaScript strings are the most important component of JavaScript, probably used more than any other data type Though you may get numeric values from web page... as well as forming the basic serialization format of every JavaScript object One of the methods that all JavaScript objects share is toString, which returns a string containing the serialized format of the object A String Primitive A JavaScript string can be both a primitive data type or an object As a primitive type, it joins with four other JavaScript primitive types: number, Boolean (true or false),...15.12 Controlling Video from JavaScript with the video Element 353 16 JavaScript Objects 359 16.1 16.2 16.3 16.4 16.5 16.6 16.7 16.8 16.9 16.10 16.11 16.12 16.13 Defining a Basic JavaScript Object Keeping Object Members Private Expanding Objects with prototype Adding Getter/Setter... I do know how to make JavaScript work with the canvas element and SVG In this chapter, I provide the basic steps needed in order to work with both of these media, as well as the newer WebGL 3D environment, and the new HTML5 video and audio elements Chapter 16, JavaScript Objects Probably one of the most important chapters in the book, this chapter covers the basics of creating JavaScript objects, including... object protection functionality, chaining object methods, and using the new Prototype.bind xviii | Preface Chapter 17, JavaScript Libraries All of the book focuses on creating your own JavaScript objects and applications This chapter introduces us to jQuery, one of the more popular JavaScript framework libraries It covers common library tasks such as how to package your code into libraries, how to test... SQL databases Chapter 21, JavaScript Outside the Box This chapter briefly gets into all the various ways that JavaScript can be used now, none of which have anything to do with traditional web page development Included are discussions on creating mobile and desktop widgets, mobile device application development, creating add-ons and extensions for browsers, as well as how JavaScript can be used with... attribution An attribution usually includes the title, author, publisher, and ISBN For example: JavaScript Cookbook, by Shelley Powers Copyright 2010 Shelley Powers, 9780596806132.” If you feel your use of code examples falls outside fair use or the permission given here, feel free to contact us at permissions @oreilly. com xx | Preface How to Contact Us Please address comments and questions concerning this . class="bi x0 y0 w0 h1" alt="" JavaScript Cookbook JavaScript Cookbook Shelley Powers Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo JavaScript Cookbook by Shelley Powers Copyright. Contents | xi Preface I wrote my first book on JavaScript 15 years ago, and had to scramble just to find enough material to fill a book. With the JavaScript Cookbook, I had to choose among hundreds of. with JavaScript and wish to try out new techniques, or increase their grasp of both fundamentals and advanced features of JavaScript. Along the way, I’ll demonstrate how to: • Work with the JavaScript
Ngày đăng: 28/04/2014, 16:59
Xem thêm: oreilly javascript cookbook, oreilly javascript cookbook, 3 Conditionally Comparing Strings, 6 Checking for an Existing, Nonempty String, 11 Left- or Right-Pad a String, 4 Finding and Highlighting All Instances of a Pattern, 6 Swap Words in a String Using Capturing Parentheses, 10 Using Function Closures with Timers, 15 Using an Associative Array to Store Form Element Names and Values, 7 Create a Function That Remembers Its State, 9 Improve Application Performance with Memoization (Caching Calculations), 10 Using an Anonymous Function to Wrap Global Variables, 2 Capturing the Location of a Mouse Click Event Using the Event Object, 3 Creating a Generic, Reusable Event Handler Function, 5 Preventing an Event from Propagating Through a Set of Nested Elements, 6 Capturing Keyboard Activity, 7 Using the New HTML5 Drag-and-Drop, 8 Using Safari Orientation Events and Other Mobile Development Environments, 7 Creating Breadcrumbs in a CMS Template Page, 8 Bookmarking a Dynamic Page, 9 Preserving State for Back Button, Page Refresh, 3 Getting Information from a Form Element Based on an Event, 9 Modifying a Selection List Based on Other Form Decisions, 1 Gracefully Handling No JavaScript Support, 6 Using Firebug with Firefox, 8 Firefox and the Console, 10 Setting a Breakpoint with IE Developer Tools, 13 Turning on Safari’s Development Tools, 15 Debugging in Chrome, 2 Accessing All Images in the Web Page, 4 Discover all Images in Articles Using the Selectors API, 6 Highlighting the First Paragraph in Every Element, 11 Summing All the Values in a Table Row, 13 Get Style Information for an Element, 2 Inserting Elements Before Existing Page Elements, 11 Replacing Links with Footnote Bullets, 12 Adding Rows to an Existing Table, 15 Changing the Element’s CSS Style Properties, 1 Determining the Area of the Web Page, 3 Locating Elements in the Page, 5 Creating Collapsible Form Sections, 6 Adding a Page Overlay, 7 Creating Tab Pages, 8 Creating Hover-Based Pop-up Info Windows, 9 Collapsing or Resizing the Sidebar, 3 Highlighting Form Field with Missing or Incorrect Data, 4 Adding Keyboard Accessibility to a Page Overlay, 6 Displaying a Flash of Color to Signal an Action, 7 Adding ARIA Attributes to a Tabbed Page Application, 3 Creating a Dynamic Line Chart in Canvas, 5 Accessing SVG from Web Page Script, 7 Enable Interactive SVG Embedded in HTML, 9 Integrating SVG and the Canvas Element in HTML, 12 Controlling Video from JavaScript with the video Element, 5 Inheriting an Object’s Functionality, 6 Extending an Object by Defining a New Property, 7 Enumerating an Object’s Properties, 11 One-Off Objects and Namespacing Your JavaScript, 13 Chaining Your Object’s Methods, 2 Testing Your Code with JsUnit, 4 Hosting Your Library, 7 Convert Your Library to a jQuery Plug-in, 8 Safely Combining Several Libraries in Your Applications, 3 Determining the Type of Query Call, 8 Populating a Selection List from the Server, 9 Using a Timer to Automatically Update the Page with Fresh Data, 10 Communicating Across Windows with PostMessage, 2 Extracting Pertinent Information from an XML Tree, 6 Convert hCalendar Microformat Annotations into a Canvas Timeline, 7 Glean Page RDFa and Convert It into JSON Using rdfQuery and the jQuery RDF Plug-in, 1 Attaching Persistent Information to URLs, 2 Creating a Cookie to Persist Information Across Pages, 4 Using sessionStorage for Client-Side Storage, 5 Creating a localStorage Client-Side Data Storage Item, 6 Persisting Data Using a Relational Data Store, 1 Creating a Browser Add-0n, Plug-in, or Extension, 2 Creating Desktop and Mobile Widgets, 4 Enhancing Tools with JavaScript, 5 Creating Efficient Desktop Applications with Web Workers and the File API