15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Image, Area,<br />

and Map Objects<br />

(Chapter 22)<br />

The IMG element object is a popular scripting target,<br />

largely because it is easy to script it for effects such as<br />

mouse rollovers. Moreover, the element’s scriptability extends<br />

backward in time to all but the very first generation of scriptable<br />

browsers. Playing a supporting role in image rollovers is<br />

the abstract Image object, which scripts use to pre-load<br />

images into the browser’s cache for instantaneous image<br />

swapping. Even though the two objects manifest themselves<br />

differently within script operations, they share properties and<br />

methods, making it easy to learn their capabilities side by<br />

side.<br />

AREA and MAP element objects work closely with each<br />

other. In practice, an AREA element resembles an A element<br />

that is set to work as a link. Both elements create clickable<br />

“hot spots” on the page that typically lead the user to other<br />

locations within the site or elsewhere on the Web. They also<br />

share a number of URL-related properties.<br />

<strong>Examples</strong> Highlights<br />

✦ Most IE browsers can load both still and motion images<br />

(such as MPEG movies) into an IMG element. Listing 22-3<br />

shows how to swap between still and motion images via<br />

the dynsrc property.<br />

✦ The page created from Listing 22-4 lets you compare the<br />

performance of swapping images with and without precaching.<br />

You also see how to have scripts rotate images<br />

on a timed schedule.<br />

✦ Watch how the IMG element’s onLoad event handler can<br />

trigger actions in Listing 22-5.<br />

✦ A powerful Listing 22-7 demonstrates how scripts can<br />

fashion new client-side area maps when a different picture<br />

file loads into an IMG element.<br />

6<br />

C H A P T E R<br />

✦ ✦ ✦ ✦<br />

In This Chapter<br />

How to precache and<br />

swap images<br />

Invoking action<br />

immediately after an<br />

image loads<br />

Creating interactive,<br />

client-side image<br />

maps<br />

✦ ✦ ✦ ✦

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!