运动框架问题
<script type="text/javascript"> function getStyle(obj,attr){ if(obj.currentStyle){ return obj.currentStyle[attr] } else{return getComputedStyle(obj,false)[attr];} }; function startMove(obj,attr,target,fn){ clearInterval(obj.timer); obj.timer=setInterval(function(){ //取当前的值 var icur=0; if(attr=="opacity"){icur=Math.round(getStyle(obj,attr)*100)}else{icur=parseInt(getStyle(obj,attr));} //设置速度 speed=(target-icur)/8; speed=speed>0?Math.ceil(speed):Math.floor(speed); //停止动画 if(icur==target){clearInterval(obj.timer);if(fn){fn()}} //obj.style.width=obj.style[attr] 注意 style[attr] else{if(attr=="opacity"){obj.style[attr]=icur;}else{obj.style[attr]=icur+speed+"px";} }},30); } </script>
DW总是提示我第三行有语法错误,自己在浏览器上引入该文件无法运行