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.
<table border="0" cellspacing="0" cellpadding="0" style="border:
1px solid #dddddd; margin-left: auto; margin-right: auto;">
<tr>
<td colspan="4" style="padding: 12px;"><img src="swap_1_large.png" width="200" height="225" alt="Image
Swap Sample" name="swap" style="border: 1px solid #dddddd;
padding: 16px;" /></td>
</tr>
<tr>
<td colspan="4"><div style="font-size: 11px; text-align:
center; padding: 0px 0px 12px 0px;">« CLICK TO ENLARGE »</div></td>
</tr>
<tr>
<td><div style="width: 50px; margin: 0px auto 12px auto;"><img
src="swap_1_large.png" width="50" height="56" alt="Thumbnail" onclick="document.swap.src=’swap_1_large.png’;" /></div></td>
<td><div style="width: 50px; margin: 0px auto 12px auto;"><img
src="swap_2_large.png" width="50" height="56" alt="Thumbnail" onclick="document.swap.src=’swap_2_large.png’;" /></div></td>
<td><div style="width: 50px; margin: 0px auto 12px auto;"><img
src="swap_3_large.png" width="50" height="56" alt="Thumbnail" onclick="document.swap.src=’swap_3_large.png’;" /></div></td>
<td><div style="width: 50px; margin: 0px auto 12px auto;"><img
src="swap_4_large.png" width="50" height="56" alt="Thumbnail" onclick="document.swap.src=’swap_4_large.png’;" /></div></td>
</tr>
</table>
1px solid #dddddd; margin-left: auto; margin-right: auto;">
<tr>
<td colspan="4" style="padding: 12px;"><img src="swap_1_large.png" width="200" height="225" alt="Image
Swap Sample" name="swap" style="border: 1px solid #dddddd;
padding: 16px;" /></td>
</tr>
<tr>
<td colspan="4"><div style="font-size: 11px; text-align:
center; padding: 0px 0px 12px 0px;">« CLICK TO ENLARGE »</div></td>
</tr>
<tr>
<td><div style="width: 50px; margin: 0px auto 12px auto;"><img
src="swap_1_large.png" width="50" height="56" alt="Thumbnail" onclick="document.swap.src=’swap_1_large.png’;" /></div></td>
<td><div style="width: 50px; margin: 0px auto 12px auto;"><img
src="swap_2_large.png" width="50" height="56" alt="Thumbnail" onclick="document.swap.src=’swap_2_large.png’;" /></div></td>
<td><div style="width: 50px; margin: 0px auto 12px auto;"><img
src="swap_3_large.png" width="50" height="56" alt="Thumbnail" onclick="document.swap.src=’swap_3_large.png’;" /></div></td>
<td><div style="width: 50px; margin: 0px auto 12px auto;"><img
src="swap_4_large.png" width="50" height="56" alt="Thumbnail" onclick="document.swap.src=’swap_4_large.png’;" /></div></td>
</tr>
</table>
![]() |
|||
|
« CLICK TO ENLARGE »
|
|||
![]() |
![]() |
![]() |
![]() |
Related posts:
- Javascript: Easy Popup Windows
- Javascript: Easy Rollover Buttons
- Formatting Tables
- Background Color & Images – Not Tables!
- Images <img>
- CSS: Menu Lists
- CSS: Padding
- CSS: Margin
- CSS: Border
- SEO: Image Optimization
- SEO: Link Building
- Menu Lists <ul>, Definition Lists <dl>
- CSS: Font Properties
- Heading Tag <h1> – <h6>
- CSS Tutorials
- Javascript Tutorials
- KDWHD Tutorials
- eBay Tutorials
- SEO Tutorials
- HTML 4.01 Strict Tutorials
- Paragraph Tags <p>
- SEO: Keyword Selection
- Beginner HTML: Your First Webpage
- CSS: External Style Sheets
- CSS Syntax
- Video: How to Install your “me” Page on eBay
- Video: How to Create Custom eBay Store Pages
- Video: How to Install Custom eBay Store Navigation
- Video: How to Install Custom eBay Store Front Page
- How Do I Add a Background Image or Color?




Comments
Leave a comment Trackback