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!

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

[About BTH]  [User Agreement]  [Privacy Policy]  [Site Map]  [Contact Form]  [Advertise on BTH]  [News Feed]

Google
Web
This Site

Easy 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>

Web Design Sections

RSS Feed RSS Feed

Easy Java Script Code
Easy Java Script Windows
Easy Rollovers
Easy Picture Transition Effects
Easy Moving Popup Code
Easy Slide Show Code
Easy Slide Show Code With Linked Slides
Slide Show with Different Size Images
Easy Picture Zoom Code
Easy Picture Panning Code
Easy Java Script Animation
Easy JavaScript Picture Selector Code
Easy Animated Banners with Java Script
Easy Java Script Form Validation
Easy Drag n Drop Code
Easy Graph Generating Code
Easy Code to Sort a Table by Column
Easy Fading Text Banner Code
Easy Expanding Banner Code
Calendars for Your Website
Date Picker For Your Web Site
Calculators For Your Web Site
Loan Payment Calculator
Length Units Converter
Body Mass Index
Fahrenheit to Celsius Converter
Decimal to Hexidecimal Converter
Easy Code for Screen Tape Adding Machine
Code for Java Script Circle⁄Sphere Calculator
Round a Float to 4 Digits to the Right of the Decimal Point
Make Your Own Graphical Digital Clock
Let Your Web site Visitors Set Font Size
How to Disable the Browser Back Button
Add More Bang to Your Content With Keyword Popup Menus
Put a Music Off Switch on Your Webpage
Java Script Random Password Generator
Password Protection Using Java Script
Replace Drop-down with Drag-and-drop
Submit Forms Without CGI
Code for a Less annoying Popup Window
Using the Java Script Array Object
Using the Java Script Date Object
Java Script Message Boxes
How to Shuffle the Deck With Java Script
Web Site Menus : Which Section Am I In?
How Far Did the User Scroll?
Where Did the User Click?
Four Ways to Use Java Script Event Handlers
Create Your Own Database Using Only Notepad : CDV

[Site User Agreement]  [Advertise on This site]  [Search This Site]  [Contact Form]
Copyright©2001-2007 Bucaro TecHelp P.O.Box 18952 Fountain Hills, AZ 85269