PDA

View Full Version : Zoom in pictures - Syntax problem!?


pheealnluot
10-06-2002, 01:25 PM
<script language = "Javascript">
<!--

pica = new Image(200,200)
pica.src = "resource/title1.jpg"
picb = new Image(200,200)
picb.src = "resource/title2.jpg"
zoomspeed=0.02 // = 2% increment


function grow (picname)
{


while (document.images(picname).width < 300)

{
document.images(picname).width += (document.images(picname).width*zoomspeed)
}

}

//-->
</script>

-------------------------------------------------------------------------------


under body

<img name=home border="0" src="resource/title1.jpg" width="200" height="200"
onmouseover="grow('home')";return true
>

-----------------------------------------------------------------

i try to make title1.jpg grow by calling function grow.
however, i keep getting the error 'object Required'..
i'm sorry if it's ambigious coz i really have no idea wat's wrong with it!
is there some syntax problem which i'm not aware of?
any help is Much appreciated! THANKS

Mr J
10-06-2002, 05:52 PM
Hi

I have tried your script and do not get any error messages at all.


The script appears to work as it should although the use of the while loop makes the zoom effect too fast to see.

As soon as you mouseover the image the width is changed to 300 without any visible size change in between, the zoomspeed=0.02 is not apparent

Simply using "document.images(picname).width =300" in the function would achieve the same effect.

If you want to actually see the image zoom then the "setTimeout" method might be better

adios
10-06-2002, 10:56 PM
document.images[picname]

glenngv
10-07-2002, 03:51 AM
...or simply

<img border="0" src="resource/title1.jpg" width="200" height="200" onmouseover="grow(this);">


function grow (pic)
{

while (pic.width < 300)
{
pic.width += pic.width*zoomspeed)
}

}