Javascript: Image Swap
This easy to follow inline Javascript is a great way to create click-to-enlarge image galleries. Or to display several pictures without loading your Web page full of images.
Besides the main image, you will want to create a second image to represent the main image. This can either be a graphic, or a thumbnail of the original image as we have done in the example below. You can also use tables to help format the positioning of the main image and thumbnails. If using this technique for a click-to-enlarge gallery, it works best to have all the photos the same size so the copy under the photos does not jump.
<div align="center" style=" width: 224px; margin-top: 12px; padding: 12px; border: 1px solid #cccccc; margin-left: auto; margin-right: auto;">
<img src="img/img_swap_1.gif" width="200" height="225" border="0" alt="Image Swap Sample" name="swap" style="padding: 12px; border: 1px solid #cccccc; margin-bottom: 4px;"><br>
« CLICK TO ENLARGE »<br>
<img src="img/img_swap_1_s.gif" width="50" height="56" alt="Thumbnail" style="margin-top: 4px;" onClick="document.swap.src='img/img_swap_1.gif';">
<img src="img/img_swap_2_s.gif" width="50" height="56" alt="Thumbnail" style="margin-top: 4px;" onClick="document.swap.src='img/img_swap_2.gif';">
<img src="img/img_swap_3_s.gif" width="50" height="56" alt="Thumbnail" style="margin-top: 4px;" onClick="document.swap.src='img/img_swap_3.gif';">
<img src="img/img_swap_4_s.gif" width="50" height="56" alt="Thumbnail" style="margin-top: 4px;" onClick="document.swap.src='img/img_swap_4.gif';">
</div>