This article provides the minimal code for four different methods to add zoom to the pictures on your Web page. The first method uses a single image. When you click on the image a JavaScript function is used to enlarge the image.
Welcome to Bucaro TecHelp!

Bucaro TecHelp
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Victims of Sandy Hook

Stop the Slaughter of Innocents. Congress is bought and paid for by gun lunatics and gun promotion groups. If you want to live in a safe America, help buy Congress back for America. Send a donation to Mayors Against Illegal Guns, 909 Third Avenue, 15th Floor New York, NY 10022

Easy Java Script Picture Zoom Code

Most of the example code that Iíve found on the web is bloated with unnecessary complexity. Maybe the authors were trying to show off their proficiency in programming. The extra complexity makes it very difficult to modify the examples for your own use.

This article provides the minimal code for four different methods to add zoom to the pictures on your Web page. The first method uses a single image. When you click on the image a JavaScript function is used to enlarge the image.

Blurry Zoom

Click on the image below and note how the image zooms in and out.

The only complexity involved with the example above is that I put the image inside a table. This stops the web page from growing and shrinking when the image changes. Note the call to the zoomBlurry() function for the onClick event of the image tag.

<table cellspacing=0 cellpadding=0 width=380 height=340>
<tr><td align="center" valign="center">
<img name="slide1" src="flamingo_s.jpg" onClick="zoomBlurry();">
</td></tr></table>

To use the zoom method demonstrated above, copy the JavaScript code below into the HEAD section of your web page. In the code change the path of the image to the path of the image that you want to zoom.

<script language="JavaScript">
var zoom1 = 0;

function zoomBlurry()
{
   if(zoom1 == 0)
   {
      zoom1 = 1;
      document.slide1.src = "flamingo_s.jpg";
      document.slide1.width = 360
      document.slide1.height = 320
   }
   else
   {
      zoom1 = 0;
      document.slide1.src = "flamingo_s.jpg";
      document.slide1.width = 180
      document.slide1.height = 160
   }
}
</script>

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro



Web Design Sections

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2016 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268