運動框架問題
<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總是提示我第三行有語法錯誤,自己在瀏覽器上引入該文件無法運行
2016-05-12
第一行<script>標簽去掉? 注意h5 <script src=""></script>引入格式
第16行在嚴格模式下是錯誤的,加上var
第21行判斷,如果是透明的話,寫全了、