Sams Teach Yourself HTML 4 in 24 Hours
- Table of Contents
- Copyright
- About the Author
- Acknowledgments
- Tell Us What You Think!
- Put Your HTML Page Online Today
- I. Your First Web Page
- Hour 1. Understanding HTML and XML
- Hour 2. Create a Web Page Right Now
- Hour 3. Linking to Other Web Pages
- Hour 4. Publishing Your HTML Pages
- II. Web Page Text
- Hour 5. Text Alignment and Lists
- Hour 6. Text Formatting and Font Control
- Hour 7. Email Links and Links Within a Page
- Hour 8. Creating HTML Forms
- III. Web Page Graphics
- Hour 9. Creating Your Own Web Page Graphics
- Hour 10. Putting Graphics on a Web Page
- Hour 11. Custom Backgrounds and Colors
- Hour 12. Creating Animated Graphics
- IV. Web Page Design
- Hour 13. Page Design and Layout
- Hour 14. Graphical Links and Imagemaps
- Hour 15. Advanced Layout with Tables
- Hour 16. Using Style Sheets
- V. Dynamic Web Pages
- Hour 17. Embedding Multimedia in Web Pages
- Hour 18. Interactive Pages with Applets and ActiveX
- Hour 19. Web Page Scripting for Non-Programmers
- Interactive Highlighting
- Preloading Images for Speed
- Adding Up an Order Form
- The Wide World of JavaScript
- Summary
- Q&A
- Workshop
- Hour 20. Setting Pages in Motion with Dynamic HTML
- VI. Building a Web Site
- Hour 21. Multipage Layout with Frames
- Hour 22. Organizing and Managing a Web Site
- Hour 23. Helping People Find Your Web Pages
- Hour 24. Planning for the Future of HTML
- VII. Appendixes
- A. Readers' Most Frequently Asked Questions
- B. HTML Learning Resources on the Internet
- C. Complete HTML 4 Quick Reference
- D. HTML Character Entities
Preloading Images for Speed
The code in Figure 19.2 works flawlessly with both Microsoft Internet Explorer and Netscape Navigator (versions 3 and later of both browsers). There is only one minor problem: The lit images won't be downloaded from your Web site until someone actually moves the mouse over the image. This can cause a significant delay before the highlighted image appears, possibly lowering the all-important Gee Whiz Factor (GWF).
You can avoid this annoyance by including some JavaScript telling the browser to preload the images as soon as possible when the page is displayed. That way, by the time the slow human reader gets around to passing his or her mouse over the link, those images will usually be ready to pop onto the screen. This makes the animations seem to appear without any download delay, giving the page a snappy feel and pumping the GWF back up to truly nerdly levels. Figure 19.5 shows how it's done.
Figure 19.5 This page looks and acts exactly like the page in Figure 19.2, except that all the "lite" images are preloaded for enhanced responsiveness.
There are a couple of things worthy of note in Figure 19.5. The most important is the <script> tag. This is used whenever you need some JavaScript that doesn't go in an attribute of some other tag. You can put <script> tags anywhere in the <head> or <body> section of a document. (The forms example later in this hour talks more about that.)
The <!-- and //--> tags just inside the <script> and </script> tags are actually comment tags, which have the effect of hiding the script from older browsers that otherwise might become confused and try to display the code as text on the page. You should always put each of these comment tags on a line by itself, as I did in Figure 19.5.
I won't go too deep into an explanation of the JavaScript in Figure 19.5 because that would get us into a course on computer programming. You don't need to understand exactly how this works in order to copy it into your own pages, using your own image names and graphics files. When you do try this on your pages, don't overlook the fact that I had to use the names from the JavaScript definitions at the top of the page instead of the actual graphics filenames. For example, the OnMouseOver attribute of the name="erica" image now looks like this:
OnMouseOver="erica.src=ercalite.src"
instead of this:
OnMouseOver="erica.src='ercalite.jpg'"
Adding Up an Order Form | Next Section

Account Sign In
View your cart