KD Web Hosting & Design Solutions

HTML, CSS, Javascript, CSS, Design, eBay Tutorials

Browsing Posts in Javascript Tutorials

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;">&laquo;&nbsp;CLICK TO ENLARGE&nbsp;&raquo;</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>
Image Swap Sample
« CLICK TO ENLARGE »
Thumbnail
Thumbnail
Thumbnail
Thumbnail

This easy to follow inline JavaScript is a popular way of letting your users see additional information without navigating away from the current page. With Javascript you can specify the dimensions, visible toolbars, and scrollbars of this newly created window. It can used to show images or HTML documents.

If you wish to have the window contain text, substitute the <img> for your own HTML.

If you are using the Javascript to display images, you will want the width/height dimensions to be about 10 pixels bigger than the side of the image to prevent visable scrollbars.

Snuggle Time
<div style="width: 156px; margin: 0px auto 9px auto;">
<a href="javascript:void(0)" onclick="window.open(‘popwindow.jpg’,'enlarge’,'width=540, height=410, menubar=no, status=no, scrollbars=yes’)" title="Snuggle Time"><img src="popwindow_thumbnail.jpg" width="150" height="111" alt="Snuggle Time" style="border: 1px solid #dddddd; padding: 3px;" /></a>
</div>