<script> function getStyle(obj,name){ if(obj.currenStyle){ return obj.currtnStyle[name]; }else{ return getComputedStyle(obj,false)[name]; } } function startMove(obj,attr,iTaret){ clearInterval(obj.timer); obj.timer=setInterval(function(){ var cur=0; if(attr="opacity"){ cur=parseFloat(getStyle(obj,attr))*100; }else{ cur=parseInt(getStyle(obj,attr)) }; var speed=(iTaret-cur)/6; speed=speed>0?Math.ceil(speed):Math.floor(speed); if(cur==iTaret){ clearInterval(obj.timer); }else{ if(attr=="opacity"){ obj.style.filter='alpha(opacity='+(cur+speed)+')'; obj.style.opacity=(cur+speed)/100; }else{ obj.style[attr]=cur+speed+'px';} } },30) } window.onload=function(){ var oDiv=document.getElementsByTagName('div'); for(var i=0;i<oDiv.length;i++){ oDiv[i].timer=i; oDiv[i].onmouseover=function(){ startMove(this,'width',400); } oDiv[i].onmouseout=function(){ startMove(this,'width',100); } } }
</script>
arlenhui
相关分类