Monday, April 14, 2008

click on button and move an image in javascript

//**********I'm also moving a div with a background image to make it appear to to scroll upward**********************************

ypos =375;
ry = 375;
height = 10;
var timer;


function movescroll(){
if(ry > 10)
{
ry= ry-10;
height = height + 10 //grow div1
obj=document.getElementById("top");
obj.style.top=ry +"px";
obj=document.getElementById("div1");
obj.style.height= height +"px";
obj.style.top= (ry + 3)+"px";
}
else
{
clearInterval(timer);
}
}
function fire(){
height = 10; // reset
ry= ypos; // reset
obj=document.getElementById("top");
obj.style.top= ry +"px";
timer=setInterval("movescroll()",5);
}

//***********add this code in img tag*************

onclick="clearInterval(timer);fire()"

0 Comments:

Post a Comment

<< Home