14.08.2016 Views

Beginning JavaScript with DOM Scripting and Ajax, 2nd Edition

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 10 ■ Modern <strong>JavaScript</strong> Case Study: A Dynamic Gallery<br />

Figure 10-1. Using <strong>JavaScript</strong> to simulate a server-controlled dynamic image gallery<br />

Displaying Captions<br />

Thumbnail galleries are visual constructs, but it is still a good idea to think about alternative text <strong>and</strong> image<br />

captioning. Not only will these make your gallery accessible to blind users, but they also allow for searching the<br />

thumbnail data <strong>and</strong> indexing it through search engines.<br />

Many tools, like Google’s Picasa, allow for dynamic captioning <strong>and</strong> the addition of alternative text. You could<br />

use XHR to create something similar, but because this is a book about <strong>JavaScript</strong>, <strong>and</strong> how to store the entered data on<br />

the server would need some explanation, it is not a relevant example. Instead, let’s modify the “fake” gallery so that it<br />

displays captions.<br />

You’ll use the image’s title attribute as a caption for the image; this means that the static HTML needs proper<br />

alternative text <strong>and</strong> title data.<br />

304<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!