Project I: Image Rollover Script

Creating and Inserting the Image Objects

Before we get to the creation of the image objects themselves, we must decide where to put our script. Because the rollovers will be on every page of the site, it makes sense to place our script into an external JavaScript file. That way, we only need to place it in a single location instead of on each page. We have already created an external JavaScript file called jsFunctions.js for one of our previous projects, so we can simply add our new script to that file. The home page already has the call to the external file, so we can just copy that <script> tag to all of the other pages on the site.

The first step in our script is to cloak for older browsers that don't support ...

Get Essential JavaScript™ for Web Professionals, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.