My Account
View Cart
Home
Community
Books & Videos
Safari Books Online
Conferences
Training
School of Technology
About
Complete List
Bestsellers
New Releases
Rough Cuts
Upcoming Titles
Ebooks
By Publisher
By Series
Out of Print
Order Info
Search
Search Tips
Tell a friend
JavaScript & DHTML Cookbook
Solutions and Example for Web Programmers
By
Danny Goodman
April 2003
Pages: 540
|
Table of Contents
|
Index
|
Sample Chapter
|
Colophon
Table of Contents
Chapter 1
Strings
Introduction
Concatenating (Joining) Strings
Accessing Substrings
Changing String Case
Testing Equality of Two Strings
Testing String Containment Without Regular Expressions
Testing String Containment with Regular Expressions
Searching and Replacing Substrings
Using Special and Escaped Characters
Reading and Writing Strings for Cookies
Converting Between Unicode Values and String Characters
Encoding and Decoding URL Strings
Encoding and Decoding Base64 Strings
Chapter 2
Numbers and Dates
Introduction
Converting Between Numbers and Strings
Testing a Number's Validity
Testing Numeric Equality
Rounding Floating-Point Numbers
Formatting Numbers for Text Display
Converting Between Decimal and Hexadecimal Numbers
Generating Pseudorandom Numbers
Calculating Trigonometric Functions
Creating a Date Object
Calculating a Previous or Future Date
Calculating the Number of Days Between Two Dates
Validating a Date
Chapter 3
Arrays and Objects
Introduction
Creating a Simple Array
Creating a Multidimensional Array
Converting Between Arrays and Strings
Doing Something with the Items in an Array
Sorting a Simple Array
Combining Arrays
Dividing Arrays
Creating a Custom Object
Simulating a Hash Table for Fast Array Lookup
Doing Something with a Property of an Object
Sorting an Array of Objects
Customizing an Object's Prototype
Converting Arrays and Custom Objects to Strings
Chapter 4
Variables, Functions, and Flow Control
Introduction
Creating a JavaScript Variable
Creating a Named Function
Nesting Named Functions
Creating an Anonymous Function
Delaying a Function Call
Branching Execution Based on Conditions
Handling Script Errors Gracefully
Improving Script Performance
Chapter 5
Browser Feature Detection
Introduction
Detecting the Browser Brand
Detecting an Early Browser Version
Detecting the Internet Explorer Version
Detecting the Netscape Navigator Version
Detecting the Client Operating System
Detecting Object Support
Detecting Object Property and Method Support
Detecting the Browser Written Language
Detecting Cookie Availability
Defining Browser- or Feature-Specific Links
Testing on Multiple Browser Versions
Chapter 6
Managing Browser Windows
Introduction
Setting the Main Window's Size
Positioning the Main Window
Maximizing the Main Window
Creating a New Window
Bringing a Window to the Front
Communicating with a New Window
Communicating Back to the Main Window
Using Internet Explorer Modal/Modeless Windows
Simulating a Cross-Browser Modal Dialog Window
Simulating a Window with Layers
Chapter 7
Managing Multiple Frames
Introduction
Creating a Blank Frame in a New Frameset
Changing the Content of One Frame from Another
Changing the Content of Multiple Frames at Once
Replacing a Frameset with a Single Page
Avoiding Being "Framed" by Another Site
Assuring a Page Loads in its Frameset
Reading a Frame's Dimensions
Resizing Frames
Setting Frameset Specifications Dynamically
Chapter 8
Dynamic Forms
Introduction
Auto-Focusing the First Text Field
Performing Common Text Field Validations
Preventing Form Submission upon Validation Failure
Auto-Focusing an Invalid Text Field Entry
Changing a Form's Action
Blocking Submissions from the Enter Key
Advancing Text Field Focus with the Enter Key
Submitting a Form by an Enter Key Press in Any Text Box
Disabling Form Controls
Hiding and Showing Form Controls
Allowing Only Numbers (or Letters) in a Text Box
Auto-Tabbing for Fixed-Length Text Boxes
Changing select Element Content
Copying Form Data Between Pages
Chapter 9
Managing Events
Introduction
Equalizing the IE and W3C Event Models
Initiating a Process After the Page Loads
Determining the Coordinates of a Click Event
Preventing an Event from Performing Its Default Behavior
Blocking Double Clicks
Determining Which Element Received an Event
Determining Which Mouse Button Was Pressed
Reading Which Character Key Was Typed
Reading Which Noncharacter Key Was Pressed
Determining Which Modifier Keys Were Pressed During an Event
Determining the Element the Cursor Rolled From/To
Synchronizing Sounds to Events
Chapter 10
Page Navigation Techniques
Introduction
Loading a New Page or Anchor
Keeping a Page Out of the Browser History
Using a select Element for Navigation
Passing Data Between Pages Via Cookies
Passing Data Between Pages Via Frames
Passing Data Between Pages Via URLs
Creating a Contextual (Right-Click) Menu
Creating Drop-Down Navigation Menus
Providing Navigation Trail Menus
Creating Expandable Menus
Creating Collapsible XML Menus
Chapter 11
Managing Style Sheets
Introduction
Assigning Style Sheet Rules to an Element Globally
Assigning Style Sheet Rules to a Subgroup of Elements
Assigning Style Sheet Rules to an Individual Element
Importing External Style Sheets
Importing Browser- or Operating System-Specific Style Sheets
Changing Imported Style Sheets After Loading
Enabling/Disabling Style Sheets
Toggling Between Style Sheets for an Element
Overriding a Style Sheet Rule
Turning Arbitrary Content into a Styled Element
Creating Center-Aligned Body Elements
Reading Effective Style Sheet Property Values
Forcing Version 6 Browsers into Standards-Compatibility Mode
Chapter 12
Visual Effects for Stationary Content
Introduction
Precaching Images
Swapping Images (Rollovers)
Changing Text Style Properties
Offering Body Text Size Choices to Users
Creating Custom Link Styles
Changing Page Background Colors and Images
Hiding and Showing Elements
Adjusting Element Transparency
Creating Transition Visual Effects
Chapter 13
Positioning HTML Elements
Introduction
Making an Element Positionable in the Document Space
Connecting a Positioned Element to a Body Element
Controlling Positioning Via a DHTML JavaScript Library
Deciding Between div and span Containers
Adjusting Positioned Element Stacking Order (z-order)
Centering an Element on Top of Another Element
Centering an Element in a Window or Frame
Determining the Location of a Nonpositioned Element
Animating Straight-Line Element Paths
Animating Circular Element Paths
Creating a Draggable Element
Scrolling div Content
Creating a Custom Scrollbar
Chapter 14
Creating Dynamic Content
Introduction
Writing Dynamic Content During Page Loading
Creating New Page Content Dynamically
Including External HTML Content
Embedding XML Data
Embedding Data as JavaScript Objects
Transforming XML Data into HTML Tables
Transforming JavaScript Objects into HTML Tables
Converting an XML Node Tree to JavaScript Objects
Creating a New Element
Creating Text Content for a New Element
Creating Mixed Element and Text Nodes
Inserting and Populating an iframe Element
Getting a Reference to an HTML Element Object
Replacing Portions of Body Content
Removing Body Content
Sorting Dynamic Tables
Walking the Document Node Tree
Capturing Document Content
Chapter 15
Dynamic Content Applications
Introduction
Displaying a Random Aphorism
Converting a User Selection into an Arbitrary Element
Automating the Search-and-Replace of Body Content
Creating a Slide Show
Auto-Scrolling the Page
Greeting Users with Their Time of Day
Displaying the Number of Days Before Christmas
Displaying a Countdown Timer
Creating a Calendar Date Picker
Displaying an Animated Progress Bar
Appendix A
Keyboard Event Character Values
Appendix B
Keyboard Key Code Values
Appendix C
ECMAScript Reserved Keywords
Colophon
Return to
JavaScript & DHTML Cookbook