Building Three-State RolloversA three-state rollover is one where the rollover has three versions. Besides the original image and the version that appears when the user places the cursor over the image, there is a third version of the image when the button itself is clicked, as shown in Figure 4.5. Figure 4.5. When the button is clicked, you get a third image (hard to see in this grayscale image; check our companion Web site for the full effect).Script 4.4, the HTML file, looks almost exactly the same as Script 4.2 from the previous task. In fact, the only differences are the document's title and the name of the external JavaScript file that is being called. That's it. This is an example of why putting all your JavaScript into an external file is so powerful; you can add functionality to your pages without having to rework your HTML pages. Script 4.4. By putting your JavaScript in an external file, the HTML for a three-state rollover is virtually identical to a two-state rollover.In Script 4.5, the external JavaScript file, there are only a few changes from Script 4.3. Rather than go through the whole script again, we'll just focus on the changes. Remember that parts of the script that we're covering are shown in red. Script 4.5. This script powers the three-state rollover.
To build a three-state rollover:
|