window.onload=function(){
var aDiv=document.getElementsByTagName('div');
aDiv[2].onclick=function(){
startMove(this,"opacity",100)
}
}
function startMove(obj, attr, iTarget)
{
clearInterval(obj.timer);
obj.timer=setInterval(function (){
var iCur=0;
var t=obj.currentStyle[attr]||getComputedStyle(obj, false)[attr];
if(attr=="opacity"){
iCur=parseInt(parseFloat(t)*100)
}
else{
iCur=parseInt(t);
}
var iSpeed=(iTarget-iCur)/8;
iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed);
if(iCur==iTarget)
{
clearInterval(obj.timer);
}
else
{
if(attr=="opacity"){
obj.style.filter="alpha(opacity:"+(iCur+iSpeed)+")";
obj.style[attr]=(iCur+iSpeed)/100;
}
else{
obj.style[attr]=iCur+iSpeed+'px';
}
}
}, 30)
}
橋本奈奈未
相关分类