»
AnglaisFrançaisVietnamien

Imprimer - Growing Image - JavaScriptBank.com

Version complète: jsB@nk » Image » Growing Image
URL: https://www.javascriptbank.com/growing-image.html

Growing Image © JavaScriptBank.comRedimensionne une image à la taille donnée à la fonction. Le nombre d'étapes et de la longueur totale de heure de la transition peut être contrôlée. Internet Explorer seulement.

Version complète: jsB@nk » Image » Growing Image
URL: https://www.javascriptbank.com/growing-image.html



JavaScript
<SCRIPT LANGUAGE="JavaScript">// Growing Image// Mike Dransfield (mike@blueroot.net)<!-- Beginvar ival, imgname, total, steps, maxx, maxy, currentx, currenty, dx, dy;function zoomImg(imgname, total, steps, maxx, maxy){// convert the total from seconds to milisecondstotal = total * 1000;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 stepstepx = maxx / steps;stepy = maxy / steps;// devide the total time (in ms) by the number of steps to get the interval timeinttime = 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;   }}//  End --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<BODY onLoad="zoomImg('test', 10, 150, 300, 200)"><img id=test src=logojs.gif border=0></body><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->