Cover image for JavaScript & DHTML Cookbook

Book description

On numerous online forums for JavaScript and DHTML, the majority of questions begin with "How do I...?" This new Cookbook provides the answers. After reading thousands of forum threads over the years, author and scripting pioneer Danny Goodman has compiled a list of problems that frequently vex scripters of various experience levels. He has now applied state-of-the-art ECMA and W3C DOM standards and used best practices to create this extensive collection of practical recipes that can bring your web pages to life. The JavaScript & DHTML Cookbook is all about adding value to the content of a web page. The book focuses on practical and sensible applications of scripting, rather than flying images and gratuitous color changes. For every problem Goodman addresses, there's a solution or "recipe"--a focused piece of code that web developers can insert directly into their applications. Yet, rather than just cut-and-paste code, you also get explanations of how and why the code works, so you can learn to adapt the problem-solving techniques to your designs. The recipes range from simple tasks, such as manipulating strings and validating dates in JavaScript, to entire libraries that demonstrate complex tasks, such as cross-browser positioning of HTML elements and sorting tables. This book contains over 150 recipes on the following topics:

  • Working with interactive forms and style sheets

  • Presenting user-friendly page navigation

  • Creating dynamic content

  • Producing visual effects for stationary content

  • Positioning HTML elements

  • Managing browser windows and multiple frames

This book is the ideal companion to O'Reilly's JavaScript: The Definitive Guide and Dynamic HTML: The Definitive Reference. If you own either of these books, the JavaScript & DHTML Cookbook is a must.

Table of Contents

  1. JavaScript & DHTML Cookbook
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Preface
      1. About You
      2. About the Recipes
      3. What's in This Book
      4. Browser Platforms
      5. Conventions Used in This Book
      6. Request for Comments
      7. Acknowledgments
    4. 1. Strings
      1. 1.0. Introduction
        1. 1.0.1. Creating a String
        2. 1.0.2. Regular Expressions
      2. 1.1. Concatenating (Joining) Strings
        1. 1.1.1. Problem
        2. 1.1.2. Solution
        3. 1.1.3. Discussion
        4. 1.1.4. See Also
      3. 1.2. Accessing Substrings
        1. 1.2.1. Problem
        2. 1.2.2. Solution
        3. 1.2.3. Discussion
        4. 1.2.4. See Also
      4. 1.3. Changing String Case
        1. 1.3.1. Problem
        2. 1.3.2. Solution
        3. 1.3.3. Discussion
        4. 1.3.4. See Also
      5. 1.4. Testing Equality of Two Strings
        1. 1.4.1. Problem
        2. 1.4.2. Solution
        3. 1.4.3. Discussion
        4. 1.4.4. See Also
      6. 1.5. Testing String Containment Without Regular Expressions
        1. 1.5.1. Problem
        2. 1.5.2. Solution
        3. 1.5.3. Discussion
        4. 1.5.4. See Also
      7. 1.6. Testing String Containment with Regular Expressions
        1. 1.6.1. Problem
        2. 1.6.2. Solution
        3. 1.6.3. Discussion
        4. 1.6.4. See Also
      8. 1.7. Searching and Replacing Substrings
        1. 1.7.1. Problem
        2. 1.7.2. Solution
        3. 1.7.3. Discussion
        4. 1.7.4. See Also
      9. 1.8. Using Special and Escaped Characters
        1. 1.8.1. Problem
        2. 1.8.2. Solution
        3. 1.8.3. Discussion
        4. 1.8.4. See Also
      10. 1.9. Reading and Writing Strings for Cookies
        1. 1.9.1. Problem
        2. 1.9.2. Solution
        3. 1.9.3. Discussion
        4. 1.9.4. See Also
      11. 1.10. Converting Between Unicode Values and String Characters
        1. 1.10.1. Problem
        2. 1.10.2. Solution
        3. 1.10.3. Discussion
        4. 1.10.4. See Also
      12. 1.11. Encoding and Decoding URL Strings
        1. 1.11.1. Problem
        2. 1.11.2. Solution
        3. 1.11.3. Discussion
        4. 1.11.4. See Also
      13. 1.12. Encoding and Decoding Base64 Strings
        1. 1.12.1. Problem
        2. 1.12.2. Solution
        3. 1.12.3. Discussion
        4. 1.12.4. See Also
    5. 2. Numbers and Dates
      1. 2.0. Introduction
        1. 2.0.1. JavaScript Numbers
        2. 2.0.2. The Math Object
        3. 2.0.3. Dates and Times
      2. 2.1. Converting Between Numbers and Strings
        1. 2.1.1. Problem
        2. 2.1.2. Solution
        3. 2.1.3. Discussion
        4. 2.1.4. See Also
      3. 2.2. Testing a Number's Validity
        1. 2.2.1. Problem
        2. 2.2.2. Solution
        3. 2.2.3. Discussion
        4. 2.2.4. See Also
      4. 2.3. Testing Numeric Equality
        1. 2.3.1. Problem
        2. 2.3.2. Solution
        3. 2.3.3. Discussion
        4. 2.3.4. See Also
      5. 2.4. Rounding Floating-Point Numbers
        1. 2.4.1. Problem
        2. 2.4.2. Solution
        3. 2.4.3. Discussion
        4. 2.4.4. See Also
      6. 2.5. Formatting Numbers for Text Display
        1. 2.5.1. Problem
        2. 2.5.2. Solution
        3. 2.5.3. Discussion
        4. 2.5.4. See Also
      7. 2.6. Converting Between Decimal and Hexadecimal Numbers
        1. 2.6.1. Problem
        2. 2.6.2. Solution
        3. 2.6.3. Discussion
        4. 2.6.4. See Also
      8. 2.7. Generating Pseudorandom Numbers
        1. 2.7.1. Problem
        2. 2.7.2. Solution
        3. 2.7.3. Discussion
        4. 2.7.4. See Also
      9. 2.8. Calculating Trigonometric Functions
        1. 2.8.1. Problem
        2. 2.8.2. Solution
        3. 2.8.3. Discussion
        4. 2.8.4. See Also
      10. 2.9. Creating a Date Object
        1. 2.9.1. Problem
        2. 2.9.2. Solution
        3. 2.9.3. Discussion
        4. 2.9.4. See Also
      11. 2.10. Calculating a Previous or Future Date
        1. 2.10.1. Problem
        2. 2.10.2. Solution
        3. 2.10.3. Discussion
        4. 2.10.4. See Also
      12. 2.11. Calculating the Number of Days Between Two Dates
        1. 2.11.1. Problem
        2. 2.11.2. Solution
        3. 2.11.3. Discussion
        4. 2.11.4. See Also
      13. 2.12. Validating a Date
        1. 2.12.1. Problem
        2. 2.12.2. Solution
        3. 2.12.3. Discussion
        4. 2.12.4. See Also
    6. 3. Arrays and Objects
      1. 3.0. Introduction
        1. 3.0.1. JavaScript Arrays
        2. 3.0.2. JavaScript Custom Objects
        3. 3.0.3. Choosing Between Arrays and Objects
        4. 3.0.4. Getting Data into the Page
      2. 3.1. Creating a Simple Array
        1. 3.1.1. Problem
        2. 3.1.2. Solution
        3. 3.1.3. Discussion
        4. 3.1.4. See Also
      3. 3.2. Creating a Multidimensional Array
        1. 3.2.1. Problem
        2. 3.2.2. Solution
        3. 3.2.3. Discussion
        4. 3.2.4. See Also
      4. 3.3. Converting Between Arrays and Strings
        1. 3.3.1. Problem
        2. 3.3.2. Solution
        3. 3.3.3. Discussion
        4. 3.3.4. See Also
      5. 3.4. Doing Something with the Items in an Array
        1. 3.4.1. Problem
        2. 3.4.2. Solution
        3. 3.4.3. Discussion
        4. 3.4.4. See Also
      6. 3.5. Sorting a Simple Array
        1. 3.5.1. Problem
        2. 3.5.2. Solution
        3. 3.5.3. Discussion
        4. 3.5.4. See Also
      7. 3.6. Combining Arrays
        1. 3.6.1. Problem
        2. 3.6.2. Solution
        3. 3.6.3. Discussion
        4. 3.6.4. See Also
      8. 3.7. Dividing Arrays
        1. 3.7.1. Problem
        2. 3.7.2. Solution
        3. 3.7.3. Discussion
        4. 3.7.4. See Also
      9. 3.8. Creating a Custom Object
        1. 3.8.1. Problem
        2. 3.8.2. Solution
        3. 3.8.3. Discussion
        4. 3.8.4. See Also
      10. 3.9. Simulating a Hash Table for Fast Array Lookup
        1. 3.9.1. Problem
        2. 3.9.2. Solution
        3. 3.9.3. Discussion
        4. 3.9.4. See Also
      11. 3.10. Doing Something with a Property of an Object
        1. 3.10.1. Problem
        2. 3.10.2. Solution
        3. 3.10.3. Discussion
        4. 3.10.4. See Also
      12. 3.11. Sorting an Array of Objects
        1. 3.11.1. Problem
        2. 3.11.2. Solution
        3. 3.11.3. Discussion
        4. 3.11.4. See Also
      13. 3.12. Customizing an Object's Prototype
        1. 3.12.1. Problem
        2. 3.12.2. Solution
        3. 3.12.3. Discussion
      14. 3.13. Converting Arrays and Custom Objects to Strings
        1. 3.13.1. Problem
        2. 3.13.2. Solution
        3. 3.13.3. Discussion
        4. 3.13.4. See Also
    7. 4. Variables, Functions, and Flow Control
      1. 4.0. Introduction
      2. 4.1. Creating a JavaScript Variable
        1. 4.1.1. Problem
        2. 4.1.2. Solution
        3. 4.1.3. Discussion
        4. 4.1.4. See Also
      3. 4.2. Creating a Named Function
        1. 4.2.1. Problem
        2. 4.2.2. Solution
        3. 4.2.3. Discussion
        4. 4.2.4. See Also
      4. 4.3. Nesting Named Functions
        1. 4.3.1. Problem
        2. 4.3.2. Solution
        3. 4.3.3. Discussion
        4. 4.3.4. See Also
      5. 4.4. Creating an Anonymous Function
        1. 4.4.1. Problem
        2. 4.4.2. Solution
        3. 4.4.3. Discussion
        4. 4.4.4. See Also
      6. 4.5. Delaying a Function Call
        1. 4.5.1. Problem
        2. 4.5.2. Solution
        3. 4.5.3. Discussion
        4. 4.5.4. See Also
      7. 4.6. Branching Execution Based on Conditions
        1. 4.6.1. Problem
        2. 4.6.2. Solution
        3. 4.6.3. Discussion
        4. 4.6.4. See Also
      8. 4.7. Handling Script Errors Gracefully
        1. 4.7.1. Problem
        2. 4.7.2. Solution
        3. 4.7.3. Discussion
      9. 4.8. Improving Script Performance
        1. 4.8.1. Problem
        2. 4.8.2. Solution
        3. 4.8.3. Discussion
        4. 4.8.4. See Also
    8. 5. Browser Feature Detection
      1. 5.0. Introduction
        1. 5.0.1. Developing a Browser Strategy
        2. 5.0.2. When There Is No JavaScript
        3. 5.0.3. Masking Scripts from Nonscriptable Browsers
        4. 5.0.4. Detecting the JavaScript Version
        5. 5.0.5. Object Detection—the Way to Go
        6. 5.0.6. Setting Global Variables
        7. 5.0.7. DHTML and Accessibility
      2. 5.1. Detecting the Browser Brand
        1. 5.1.1. Problem
        2. 5.1.2. Solution
        3. 5.1.3. Discussion
        4. 5.1.4. See Also
      3. 5.2. Detecting an Early Browser Version
        1. 5.2.1. Problem
        2. 5.2.2. Solution
        3. 5.2.3. Discussion
        4. 5.2.4. See Also
      4. 5.3. Detecting the Internet Explorer Version
        1. 5.3.1. Problem
        2. 5.3.2. Solution
        3. 5.3.3. Discussion
        4. 5.3.4. See Also
      5. 5.4. Detecting the Netscape Navigator Version
        1. 5.4.1. Problem
        2. 5.4.2. Solution
        3. 5.4.3. Discussion
        4. 5.4.4. See Also
      6. 5.5. Detecting the Client Operating System
        1. 5.5.1. Problem
        2. 5.5.2. Solution
        3. 5.5.3. Discussion
        4. 5.5.4. See Also
      7. 5.6. Detecting Object Support
        1. 5.6.1. Problem
        2. 5.6.2. Solution
        3. 5.6.3. Discussion
        4. 5.6.4. See Also
      8. 5.7. Detecting Object Property and Method Support
        1. 5.7.1. Problem
        2. 5.7.2. Solution
        3. 5.7.3. Discussion
        4. 5.7.4. See Also
      9. 5.8. Detecting the Browser Written Language
        1. 5.8.1. Problem
        2. 5.8.2. Solution
        3. 5.8.3. Discussion
        4. 5.8.4. See Also
      10. 5.9. Detecting Cookie Availability
        1. 5.9.1. Problem
        2. 5.9.2. Solution
        3. 5.9.3. Discussion
        4. 5.9.4. See Also
      11. 5.10. Defining Browser- or Feature-Specific Links
        1. 5.10.1. Problem
        2. 5.10.2. Solution
        3. 5.10.3. Discussion
        4. 5.10.4. See Also
      12. 5.11. Testing on Multiple Browser Versions
        1. 5.11.1. Problem
        2. 5.11.2. Solution
        3. 5.11.3. Discussion
    9. 6. Managing Browser Windows
      1. 6.0. Introduction
        1. 6.0.1. Window Abuse
        2. 6.0.2. Window No-Nos
      2. 6.1. Setting the Main Window's Size
        1. 6.1.1. Problem
        2. 6.1.2. Solution
        3. 6.1.3. Discussion
        4. 6.1.4. See Also
      3. 6.2. Positioning the Main Window
        1. 6.2.1. Problem
        2. 6.2.2. Solution
        3. 6.2.3. Discussion
        4. 6.2.4. See Also
      4. 6.3. Maximizing the Main Window
        1. 6.3.1. Problem
        2. 6.3.2. Solution
        3. 6.3.3. Discussion
        4. 6.3.4. See Also
      5. 6.4. Creating a New Window
        1. 6.4.1. Problem
        2. 6.4.2. Solution
        3. 6.4.3. Discussion
        4. 6.4.4. See Also
      6. 6.5. Bringing a Window to the Front
        1. 6.5.1. Problem
        2. 6.5.2. Solution
        3. 6.5.3. Discussion
        4. 6.5.4. See Also
      7. 6.6. Communicating with a New Window
        1. 6.6.1. Problem
        2. 6.6.2. Solution
        3. 6.6.3. Discussion
        4. 6.6.4. See Also
      8. 6.7. Communicating Back to the Main Window
        1. 6.7.1. Problem
        2. 6.7.2. Solution
        3. 6.7.3. Discussion
        4. 6.7.4. See Also
      9. 6.8. Using Internet Explorer Modal/Modeless Windows
        1. 6.8.1. Problem
        2. 6.8.2. Solution
        3. 6.8.3. Discussion
        4. 6.8.4. See Also
      10. 6.9. Simulating a Cross-Browser Modal Dialog Window
        1. 6.9.1. Problem
        2. 6.9.2. Solution
        3. 6.9.3. Discussion
        4. 6.9.4. See Also
      11. 6.10. Simulating a Window with Layers
        1. 6.10.1. Problem
        2. 6.10.2. Solution
        3. 6.10.3. Discussion
        4. 6.10.4. See Also
    10. 7. Managing Multiple Frames
      1. 7.0. Introduction
        1. 7.0.1. Frames as Window Objects
        2. 7.0.2. Framesets and Frames as Elements
        3. 7.0.3. Frames and Events
        4. 7.0.4. Hidden Frames
        5. 7.0.5. Frame No-Nos
      2. 7.1. Creating a Blank Frame in a New Frameset
        1. 7.1.1. Problem
        2. 7.1.2. Solution
        3. 7.1.3. Discussion
        4. 7.1.4. See Also
      3. 7.2. Changing the Content of One Frame from Another
        1. 7.2.1. Problem
        2. 7.2.2. Solution
        3. 7.2.3. Discussion
        4. 7.2.4. See Also
      4. 7.3. Changing the Content of Multiple Frames at Once
        1. 7.3.1. Problem
        2. 7.3.2. Solution
        3. 7.3.3. Discussion
        4. 7.3.4. See Also
      5. 7.4. Replacing a Frameset with a Single Page
        1. 7.4.1. Problem
        2. 7.4.2. Solution
        3. 7.4.3. Discussion
        4. 7.4.4. See Also
      6. 7.5. Avoiding Being "Framed" by Another Site
        1. 7.5.1. Problem
        2. 7.5.2. Solution
        3. 7.5.3. Discussion
        4. 7.5.4. See Also
      7. 7.6. Assuring a Page Loads in its Frameset
        1. 7.6.1. Problem
        2. 7.6.2. Solution
        3. 7.6.3. Discussion
        4. 7.6.4. See Also
      8. 7.7. Reading a Frame's Dimensions
        1. 7.7.1. Problem
        2. 7.7.2. Solution
        3. 7.7.3. Discussion
        4. 7.7.4. See Also
      9. 7.8. Resizing Frames
        1. 7.8.1. Problem
        2. 7.8.2. Solution
        3. 7.8.3. Discussion
        4. 7.8.4. See Also
      10. 7.9. Setting Frameset Specifications Dynamically
        1. 7.9.1. Problem
        2. 7.9.2. Solution
        3. 7.9.3. Discussion
        4. 7.9.4. See Also
    11. 8. Dynamic Forms
      1. 8.0. Introduction
        1. 8.0.1. Referencing Forms and Controls
        2. 8.0.2. Form Validation Strategies
        3. 8.0.3. Email Submissions and Return Pages
      2. 8.1. Auto-Focusing the First Text Field
        1. 8.1.1. Problem
        2. 8.1.2. Solution
        3. 8.1.3. Discussion
        4. 8.1.4. See Also
      3. 8.2. Performing Common Text Field Validations
        1. 8.2.1. Problem
        2. 8.2.2. Solution
        3. 8.2.3. Discussion
        4. 8.2.4. See Also
      4. 8.3. Preventing Form Submission upon Validation Failure
        1. 8.3.1. Problem
        2. 8.3.2. Solution
        3. 8.3.3. Discussion
        4. 8.3.4. See Also
      5. 8.4. Auto-Focusing an Invalid Text Field Entry
        1. 8.4.1. Problem
        2. 8.4.2. Solution
        3. 8.4.3. Discussion
        4. 8.4.4. See Also
      6. 8.5. Changing a Form's Action
        1. 8.5.1. Problem
        2. 8.5.2. Solution
        3. 8.5.3. Discussion
        4. 8.5.4. See Also
      7. 8.6. Blocking Submissions from the Enter Key
        1. 8.6.1. Problem
        2. 8.6.2. Solution
        3. 8.6.3. Discussion
        4. 8.6.4. See Also
      8. 8.7. Advancing Text Field Focus with the Enter Key
        1. 8.7.1. Problem
        2. 8.7.2. Solution
        3. 8.7.3. Discussion
        4. 8.7.4. See Also
      9. 8.8. Submitting a Form by an Enter Key Press in Any Text Box
        1. 8.8.1. Problem
        2. 8.8.2. Solution
        3. 8.8.3. Discussion
        4. 8.8.4. See Also
      10. 8.9. Disabling Form Controls
        1. 8.9.1. Problem
        2. 8.9.2. Solution
        3. 8.9.3. Discussion
        4. 8.9.4. See Also
      11. 8.10. Hiding and Showing Form Controls
        1. 8.10.1. Problem
        2. 8.10.2. Solution
        3. 8.10.3. Discussion
        4. 8.10.4. See Also
      12. 8.11. Allowing Only Numbers (or Letters) in a Text Box
        1. 8.11.1. Problem
        2. 8.11.2. Solution
        3. 8.11.3. Discussion
        4. 8.11.4. See Also
      13. 8.12. Auto-Tabbing for Fixed-Length Text Boxes
        1. 8.12.1. Problem
        2. 8.12.2. Solution
        3. 8.12.3. Discussion
        4. 8.12.4. See Also
      14. 8.13. Changing select Element Content
        1. 8.13.1. Problem
        2. 8.13.2. Solution
        3. 8.13.3. Discussion
        4. 8.13.4. See Also
      15. 8.14. Copying Form Data Between Pages
        1. 8.14.1. Problem
        2. 8.14.2. Solution
        3. 8.14.3. Discussion
        4. 8.14.4. See Also
    12. 9. Managing Events
      1. 9.0. Introduction
        1. 9.0.1. The Event-Scripting Process
        2. 9.0.2. Event Types
        3. 9.0.3. Event Models
      2. 9.1. Equalizing the IE and W3C Event Models
        1. 9.1.1. Problem
        2. 9.1.2. Solution
        3. 9.1.3. Discussion
        4. 9.1.4. See Also
      3. 9.2. Initiating a Process After the Page Loads
        1. 9.2.1. Problem
        2. 9.2.2. Solution
        3. 9.2.3. Discussion
        4. 9.2.4. See Also
      4. 9.3. Determining the Coordinates of a Click Event
        1. 9.3.1. Problem
        2. 9.3.2. Solution
        3. 9.3.3. Discussion
        4. 9.3.4. See Also
      5. 9.4. Preventing an Event from Performing Its Default Behavior
        1. 9.4.1. Problem
        2. 9.4.2. Solution
        3. 9.4.3. Discussion
        4. 9.4.4. See Also
      6. 9.5. Blocking Double Clicks
        1. 9.5.1. Problem
        2. 9.5.2. Solution
        3. 9.5.3. Discussion
        4. 9.5.4. See Also
      7. 9.6. Determining Which Element Received an Event
        1. 9.6.1. Problem
        2. 9.6.2. Solution
        3. 9.6.3. Discussion
        4. 9.6.4. See Also
      8. 9.7. Determining Which Mouse Button Was Pressed
        1. 9.7.1. Problem
        2. 9.7.2. Solution
        3. 9.7.3. Discussion
        4. 9.7.4. See Also
      9. 9.8. Reading Which Character Key Was Typed
        1. 9.8.1. Problem
        2. 9.8.2. Solution
        3. 9.8.3. Discussion
        4. 9.8.4. See Also
      10. 9.9. Reading Which Noncharacter Key Was Pressed
        1. 9.9.1. Problem
        2. 9.9.2. Solution
        3. 9.9.3. Discussion
        4. 9.9.4. See Also
      11. 9.10. Determining Which Modifier Keys Were Pressed During an Event
        1. 9.10.1. Problem
        2. 9.10.2. Solution
        3. 9.10.3. Discussion
        4. 9.10.4. See Also
      12. 9.11. Determining the Element the Cursor Rolled From/To
        1. 9.11.1. Problem
        2. 9.11.2. Solution
        3. 9.11.3. Discussion
        4. 9.11.4. See Also
      13. 9.12. Synchronizing Sounds to Events
        1. 9.12.1. Problem
        2. 9.12.2. Solution
        3. 9.12.3. Discussion
        4. 9.12.4. See Also
    13. 10. Page Navigation Techniques
      1. 10.0. Introduction
        1. 10.0.1. The location Object
        2. 10.0.2. Passing Data Between Pages
        3. 10.0.3. Pop-Up/Drop-Down Navigation Menus
        4. 10.0.4. Default Data Delivery to a Page
      2. 10.1. Loading a New Page or Anchor
        1. 10.1.1. Problem
        2. 10.1.2. Solution
        3. 10.1.3. Discussion
        4. 10.1.4. See Also
      3. 10.2. Keeping a Page Out of the Browser History
        1. 10.2.1. Problem
        2. 10.2.2. Solution
        3. 10.2.3. Discussion
        4. 10.2.4. See Also
      4. 10.3. Using a select Element for Navigation
        1. 10.3.1. Problem
        2. 10.3.2. Solution
        3. 10.3.3. Discussion
        4. 10.3.4. See Also
      5. 10.4. Passing Data Between Pages Via Cookies
        1. 10.4.1. Problem
        2. 10.4.2. Solution
        3. 10.4.3. Discussion
        4. 10.4.4. See Also
      6. 10.5. Passing Data Between Pages Via Frames
        1. 10.5.1. Problem
        2. 10.5.2. Solution
        3. 10.5.3. Discussion
        4. 10.5.4. See Also
      7. 10.6. Passing Data Between Pages Via URLs
        1. 10.6.1. Problem
        2. 10.6.2. Solution
        3. 10.6.3. Discussion
        4. 10.6.4. See Also
      8. 10.7. Creating a Contextual (Right-Click) Menu
        1. 10.7.1. Problem
        2. 10.7.2. Solution
        3. 10.7.3. Discussion
        4. 10.7.4. See Also
      9. 10.8. Creating Drop-Down Navigation Menus
        1. 10.8.1. Problem
        2. 10.8.2. Solution
        3. 10.8.3. Discussion
        4. 10.8.4. See Also
      10. 10.9. Providing Navigation Trail Menus
        1. 10.9.1. Problem
        2. 10.9.2. Solution
        3. 10.9.3. Discussion
        4. 10.9.4. See Also
      11. 10.10. Creating Expandable Menus
        1. 10.10.1. Problem
        2. 10.10.2. Solution
        3. 10.10.3. Discussion
        4. 10.10.4. See Also
      12. 10.11. Creating Collapsible XML Menus
        1. 10.11.1. Problem
        2. 10.11.2. Solution
        3. 10.11.3. Discussion
        4. 10.11.4. See Also
    14. 11. Managing Style Sheets
      1. 11.0. Introduction
        1. 11.0.1. Adding Styles to a Document
        2. 11.0.2. Style Sheet Rule Syntax
        3. 11.0.3. The Cascade and Specificity
      2. 11.1. Assigning Style Sheet Rules to an Element Globally
        1. 11.1.1. Problem
        2. 11.1.2. Solution
        3. 11.1.3. Discussion
        4. 11.1.4. See Also
      3. 11.2. Assigning Style Sheet Rules to a Subgroup of Elements
        1. 11.2.1. Problem
        2. 11.2.2. Solution
        3. 11.2.3. Discussion
        4. 11.2.4. See Also
      4. 11.3. Assigning Style Sheet Rules to an Individual Element
        1. 11.3.1. Problem
        2. 11.3.2. Solution
        3. 11.3.3. Discussion
        4. 11.3.4. See Also
      5. 11.4. Importing External Style Sheets
        1. 11.4.1. Problem
        2. 11.4.2. Solution
        3. 11.4.3. Discussion
        4. 11.4.4. See Also
      6. 11.5. Importing Browser- or Operating System-Specific Style Sheets
        1. 11.5.1. Problem
        2. 11.5.2. Solution
        3. 11.5.3. Discussion
        4. 11.5.4. See Also
      7. 11.6. Changing Imported Style Sheets After Loading
        1. 11.6.1. Problem
        2. 11.6.2. Solution
        3. 11.6.3. Discussion
        4. 11.6.4. See Also
      8. 11.7. Enabling/Disabling Style Sheets
        1. 11.7.1. Problem
        2. 11.7.2. Solution
        3. 11.7.3. Discussion
        4. 11.7.4. See Also
      9. 11.8. Toggling Between Style Sheets for an Element
        1. 11.8.1. Problem
        2. 11.8.2. Solution
        3. 11.8.3. Discussion
        4. 11.8.4. See Also
      10. 11.9. Overriding a Style Sheet Rule
        1. 11.9.1. Problem
        2. 11.9.2. Solution
        3. 11.9.3. Discussion
        4. 11.9.4. See Also
      11. 11.10. Turning Arbitrary Content into a Styled Element
        1. 11.10.1. Problem
        2. 11.10.2. Solution
        3. 11.10.3. Discussion
        4. 11.10.4. See Also
      12. 11.11. Creating Center-Aligned Body Elements
        1. 11.11.1. Problem
        2. 11.11.2. Solution
        3. 11.11.3. Discussion
        4. 11.11.4. See Also
      13. 11.12. Reading Effective Style Sheet Property Values
        1. 11.12.1. Problem
        2. 11.12.2. Solution
        3. 11.12.3. Discussion
        4. 11.12.4. See Also
      14. 11.13. Forcing Version 6 Browsers into Standards-Compatibility Mode
        1. 11.13.1. Problem
        2. 11.13.2. Solution
        3. 11.13.3. Discussion
        4. 11.13.4. See Also
    15. 12. Visual Effects for Stationary Content
      1. 12.0. Introduction
        1. 12.0.1. Referencing Element Objects
        2. 12.0.2. Referencing Elements from Events
        3. 12.0.3. Getting to an Element's Style
      2. 12.1. Precaching Images
        1. 12.1.1. Problem
        2. 12.1.2. Solution
        3. 12.1.3. Discussion
        4. 12.1.4. See Also
      3. 12.2. Swapping Images (Rollovers)
        1. 12.2.1. Problem
        2. 12.2.2. Solution
        3. 12.2.3. Discussion
        4. 12.2.4. See Also
      4. 12.3. Changing Text Style Properties
        1. 12.3.1. Problem
        2. 12.3.2. Solution
        3. 12.3.3. Discussion
        4. 12.3.4. See Also
      5. 12.4. Offering Body Text Size Choices to Users
        1. 12.4.1. Problem
        2. 12.4.2. Solution
        3. 12.4.3. Discussion
        4. 12.4.4. See Also
      6. 12.5. Creating Custom Link Styles
        1. 12.5.1. Problem
        2. 12.5.2. Solution
        3. 12.5.3. Discussion
        4. 12.5.4. See Also
      7. 12.6. Changing Page Background Colors and Images
        1. 12.6.1. Problem
        2. 12.6.2. Solution
        3. 12.6.3. Discussion
        4. 12.6.4. See Also
      8. 12.7. Hiding and Showing Elements
        1. 12.7.1. Problem
        2. 12.7.2. Solution
        3. 12.7.3. Discussion
        4. 12.7.4. See Also
      9. 12.8. Adjusting Element Transparency
        1. 12.8.1. Problem
        2. 12.8.2. Solution
        3. 12.8.3. Discussion
        4. 12.8.4. See Also
      10. 12.9. Creating Transition Visual Effects
        1. 12.9.1. Problem
        2. 12.9.2. Solution
        3. 12.9.3. Discussion
        4. 12.9.4. See Also
    16. 13. Positioning HTML Elements
      1. 13.0. Introduction
        1. 13.0.1. Positioning Scope
        2. 13.0.2. Positioning Types
        3. 13.0.3. Evolving Contexts
        4. 13.0.4. Incompatibility Hazards
        5. 13.0.5. Units of Measure
        6. 13.0.6. The Erstwhile <layer> Tag
      2. 13.1. Making an Element Positionable in the Document Space
        1. 13.1.1. Problem
        2. 13.1.2. Solution
        3. 13.1.3. Discussion
        4. 13.1.4. See Also
      3. 13.2. Connecting a Positioned Element to a Body Element
        1. 13.2.1. Problem
        2. 13.2.2. Solution
        3. 13.2.3. Discussion
        4. 13.2.4. See Also
      4. 13.3. Controlling Positioning Via a DHTML JavaScript Library
        1. 13.3.1. Problem
        2. 13.3.2. Solution
        3. 13.3.3. Discussion
        4. 13.3.4. See Also
      5. 13.4. Deciding Between div and span Containers
        1. 13.4.1. Problem
        2. 13.4.2. Solution
        3. 13.4.3. Discussion
        4. 13.4.4. See Also
      6. 13.5. Adjusting Positioned Element Stacking Order (z-order)
        1. 13.5.1. Problem
        2. 13.5.2. Solution
        3. 13.5.3. Discussion
        4. 13.5.4. See Also
      7. 13.6. Centering an Element on Top of Another Element
        1. 13.6.1. Problem
        2. 13.6.2. Solution
        3. 13.6.3. Discussion
        4. 13.6.4. See Also
      8. 13.7. Centering an Element in a Window or Frame
        1. 13.7.1. Problem
        2. 13.7.2. Solution
        3. 13.7.3. Discussion
        4. 13.7.4. See Also
      9. 13.8. Determining the Location of a Nonpositioned Element
        1. 13.8.1. Problem
        2. 13.8.2. Solution
        3. 13.8.3. Discussion
        4. 13.8.4. See Also
      10. 13.9. Animating Straight-Line Element Paths
        1. 13.9.1. Problem
        2. 13.9.2. Solution
        3. 13.9.3. Discussion
        4. 13.9.4. See Also
      11. 13.10. Animating Circular Element Paths
        1. 13.10.1. Problem
        2. 13.10.2. Solution
        3. 13.10.3. Discussion
        4. 13.10.4. See Also
      12. 13.11. Creating a Draggable Element
        1. 13.11.1. Problem
        2. 13.11.2. Solution
        3. 13.11.3. Discussion
        4. 13.11.4. See Also
      13. 13.12. Scrolling div Content
        1. 13.12.1. Problem
        2. 13.12.2. Solution
        3. 13.12.3. Discussion
        4. 13.12.4. See Also
      14. 13.13. Creating a Custom Scrollbar
        1. 13.13.1. Problem
        2. 13.13.2. Solution
        3. 13.13.3. Discussion
        4. 13.13.4. See Also
    17. 14. Creating Dynamic Content
      1. 14.0. Introduction
      2. 14.1. Writing Dynamic Content During Page Loading
        1. 14.1.1. Problem
        2. 14.1.2. Solution
        3. 14.1.3. Discussion
        4. 14.1.4. See Also
      3. 14.2. Creating New Page Content Dynamically
        1. 14.2.1. Problem
        2. 14.2.2. Solution
        3. 14.2.3. Discussion
        4. 14.2.4. See Also
      4. 14.3. Including External HTML Content
        1. 14.3.1. Problem
        2. 14.3.2. Solution
        3. 14.3.3. Discussion
        4. 14.3.4. See Also
      5. 14.4. Embedding XML Data
        1. 14.4.1. Problem
        2. 14.4.2. Solution
        3. 14.4.3. Discussion
        4. 14.4.4. See Also
      6. 14.5. Embedding Data as JavaScript Objects
        1. 14.5.1. Problem
        2. 14.5.2. Solution
        3. 14.5.3. Discussion
        4. 14.5.4. See Also
      7. 14.6. Transforming XML Data into HTML Tables
        1. 14.6.1. Problem
        2. 14.6.2. Solution
        3. 14.6.3. Discussion
        4. 14.6.4. See Also
      8. 14.7. Transforming JavaScript Objects into HTML Tables
        1. 14.7.1. Problem
        2. 14.7.2. Solution
        3. 14.7.3. Discussion
        4. 14.7.4. See Also
      9. 14.8. Converting an XML Node Tree to JavaScript Objects
        1. 14.8.1. Problem
        2. 14.8.2. Solution
        3. 14.8.3. Discussion
        4. 14.8.4. See Also
      10. 14.9. Creating a New Element
        1. 14.9.1. Problem
        2. 14.9.2. Solution
        3. 14.9.3. Discussion
        4. 14.9.4. See Also
      11. 14.10. Creating Text Content for a New Element
        1. 14.10.1. Problem
        2. 14.10.2. Solution
        3. 14.10.3. Discussion
        4. 14.10.4. See Also
      12. 14.11. Creating Mixed Element and Text Nodes
        1. 14.11.1. Problem
        2. 14.11.2. Solution
        3. 14.11.3. Discussion
        4. 14.11.4. See Also
      13. 14.12. Inserting and Populating an iframe Element
        1. 14.12.1. Problem
        2. 14.12.2. Solution
        3. 14.12.3. Discussion
        4. 14.12.4. See Also
      14. 14.13. Getting a Reference to an HTML Element Object
        1. 14.13.1. Problem
        2. 14.13.2. Solution
        3. 14.13.3. Discussion
        4. 14.13.4. See Also
      15. 14.14. Replacing Portions of Body Content
        1. 14.14.1. Problem
        2. 14.14.2. Solution
        3. 14.14.3. Discussion
        4. 14.14.4. See Also
      16. 14.15. Removing Body Content
        1. 14.15.1. Problem
        2. 14.15.2. Solution
        3. 14.15.3. Discussion
        4. 14.15.4. See Also
      17. 14.16. Sorting Dynamic Tables
        1. 14.16.1. Problem
        2. 14.16.2. Solution
        3. 14.16.3. Discussion
        4. 14.16.4. See Also
      18. 14.17. Walking the Document Node Tree
        1. 14.17.1. Problem
        2. 14.17.2. Solution
        3. 14.17.3. Discussion
        4. 14.17.4. See Also
      19. 14.18. Capturing Document Content
        1. 14.18.1. Problem
        2. 14.18.2. Solution
        3. 14.18.3. Discussion
        4. 14.18.4. See Also
    18. 15. Dynamic Content Applications
      1. 15.0. Introduction
      2. 15.1. Displaying a Random Aphorism
        1. 15.1.1. Problem
        2. 15.1.2. Solution
        3. 15.1.3. Discussion
        4. 15.1.4. See Also
      3. 15.2. Converting a User Selection into an Arbitrary Element
        1. 15.2.1. Problem
        2. 15.2.2. Solution
        3. 15.2.3. Discussion
        4. 15.2.4. See Also
      4. 15.3. Automating the Search-and-Replace of Body Content
        1. 15.3.1. Problem
        2. 15.3.2. Solution
        3. 15.3.3. Discussion
        4. 15.3.4. See Also
      5. 15.4. Creating a Slide Show
        1. 15.4.1. Problem
        2. 15.4.2. Solution
        3. 15.4.3. Discussion
        4. 15.4.4. See Also
      6. 15.5. Auto-Scrolling the Page
        1. 15.5.1. Problem
        2. 15.5.2. Solution
        3. 15.5.3. Discussion
        4. 15.5.4. See Also
      7. 15.6. Greeting Users with Their Time of Day
        1. 15.6.1. Problem
        2. 15.6.2. Solution
        3. 15.6.3. Discussion
        4. 15.6.4. See Also
      8. 15.7. Displaying the Number of Days Before Christmas
        1. 15.7.1. Problem
        2. 15.7.2. Solution
        3. 15.7.3. Discussion
        4. 15.7.4. See Also
      9. 15.8. Displaying a Countdown Timer
        1. 15.8.1. Problem
        2. 15.8.2. Solution
        3. 15.8.3. Discussion
        4. 15.8.4. See Also
      10. 15.9. Creating a Calendar Date Picker
        1. 15.9.1. Problem
        2. 15.9.2. Solution
        3. 15.9.3. Discussion
        4. 15.9.4. See Also
      11. 15.10. Displaying an Animated Progress Bar
        1. 15.10.1. Problem
        2. 15.10.2. Solution
        3. 15.10.3. Discussion
        4. 15.10.4. See Also
    19. A. Keyboard Event Character Values
    20. B. Keyboard Key Code Values
    21. C. ECMAScript Reserved Keywords
    22. Index
    23. About the Author
    24. Colophon
    25. SPECIAL OFFER: Upgrade this ebook with O’Reilly