Tulos

Klikkaamalla laajentuva kuva?

Esimerkkikuva laajentumista varten.

Koodi

Tämä tulee HEAD-osastoon

<script type="text/javascript">
//<![CDATA[
// Original: Mike Dransfield
// Modified: Osmo Saarikumpu 2008-01-07
var ival, imgname, total, steps, maxx, maxy, currentx, currenty, dx, dy;
function zImg(imgname, total, steps, maxx, maxy) {

// muuta ao. lukua laajenemisnopeuden säätämiseksi:
total = total * 50;

objref = eval("document.getElementById('"+imgname+"')");
currentx = objref.width;
currenty = objref.height;
// work out how much we need to increase the image by each step
// devide image sizes by number of steps to get the amount we need to change each step
stepx = maxx / steps;
stepy = maxy / steps;
// divide the total time by the number of steps to get the interval time
inttime = total / steps;
// set the interval to increase the size of the image by the required pixels
functionRef = "resizeImg('"+imgname+"', "+stepx+", "+stepy+", "+maxx+", "+maxy+")";
ival = setInterval(functionRef, inttime);
}
function resizeImg(imgname, dx, dy, maxx, maxy) {
objref = eval("document.getElementById('"+imgname+"')");
currentx = objref.width;
currenty = objref.height;
if ((currentx<maxx-dx) && (currenty<maxy-dy)) {
objref.height = currenty + dy;
objref.width = currentx + dx;
}
else {
clearInterval(ival);
objref.height = maxy;
objref.width = maxx;
   }
}
//]]>
</script>

Tämä tulee BODY-osastoon

<div>
<img
 onclick="this.height<99?zImg('Nimi',28,34,343,288):zImg('Nimi',0,0,68,56)"
 src="../../../images/a-o.jpg"
 width="68"
 height="56"
 alt="Esimerkkikuva laajentumista varten."
 id="Nimi" />
</div>
Weppipakin kotisivulle