By James Edwards & Cameron Adams
Expert Reviewers: Bobby van der Sluis & Derek Featherstone
Among the 101 Tips, Tricks & Hacks you'll learn how-to:
- Create a slick yet accessible drop-down menu system
- Take control of your web pages with the DOM
- Validate forms in real time using regular expressions
- Optimize your code so that it runs faster
- Manage style sheets and modify styles on-the-fly
- Produce sophisticated drag-and-drop interaction
- Enhance your site with slick, animated transitions
- Create AJAX applications with the XMLHttpRequest object
...and much more besides!
What's in the book?
Chapter 2: Working with Numbers
Chapter 3: Working with Strings
Chapter 4: Working with Arrays
Chapter 5: Navigating the Document Object Model
The DOM is an interface for manipulating individual parts of a document. This chapter introduces and explores the DOM, and looks at how to create and read the data from elements, attributes and text.
Chapter 6: Processing and Validating Forms
In this chapter we look at reading and writing data from different kinds of form widget, validating and processing form data, and improving the usability of form-based interfaces.
Chapter 7: Working with Windows and Frames
Chapter 8: Working with Cookies
Chapter 9: Working with Date and Time
Chapter 10: Working with Images
Images are still an important part of most web designs, and in this chapter we look at the basic techniques involved in scripting for them. The chapter moves from simple tasks like pre-loading, randomly-selecting, swapping and cross-fading of images, through to more complex slideshow, progress-indicator and image-based clock scripts.
Chapter 11: Detecting Browser Differences
This short chapter outlines techniques for dealing with different browsers and rendering modes, when and where it's appropriate to use browser detection or object detection, and how to combine those techniques to get the most robust information.
In this chapter we'll look at how to read and write the styles from a single element or group of elements, how to read and write CSS rules to an existing or created style sheet, and how to build a style sheet switcher.
Chapter 13: Basic Dynamic HTML
DHTML uses HTML, the DOM and CSS to bring static content to life, and although the term DHTML is disparaged in some quarters, we still believe it's a useful and relevant way of describing this kind of scripting. In this chapter we'll cover event-handling in all its flavors, detecting the position and size of an object, tracking the mouse, and making elements appear or disappear. We'll also begin to look at re-arranging the DOM dynamically, with a neat table-sorting script.
Chapter 14: Time and Motion
Chapter 15: DHTML Menus and Navigation
This chapter enters the complex arena of DHTML menus with two major scripts - a dropdown or flyout menu, and a foldertree or expanding menu. For each menu we'll create a core navigation structure using clean, semantic code, then we'll improve on each script with usability and accessibility enhancements, including submenu indicator arrows, open and close timers, and automatic repositioning (so that a menu never goes over the edge). This chapter also includes solutions for the problem of menus going over select elements in Windows IE5 and IE6.
This chapter delves into the exciting area of online application design, including data retrieval using XMLHttpRequest, as well as the older technique of using an iframe. We'll also talk about creating custom dialogs, building editable elements like rich-text entry fields, and controlling and creating text-selections to make an auto-complete search field.
Object Orientation is generally considered the best approach to large-scale programming projects, and in this chapter we introduce OOP, its core concepts and benefits. We'll cover the practical techniques involved in creating an object-oriented or object-based script, and we'll talk about scope, inheritance, and object-namespacing.
Chapter 20: Keeping up the pace
The final chapter looks at everyday techniques for writing faster, more efficient code, that's smaller and uses less memory. We'll also cover more brutal techniques for optimizing and obfuscating production code, but with a cautious mind to remember that some optimizations are more trouble than they're worth!