能不能帮我看看问题在哪里呢? 麻烦了
function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}else{
return getComputedStyle(obj,false)[attr];
}
}
function startMove(obj,json,fn){
obj.timer=null;
clearInterval(obj.timer);
obj.timer=setInterval(function(){
for(var attr in json){
var flag=true;
var speed=0;
var icur;
if(attr=="opacity"){
icur=Math.round(parseFloat(getStyle(obj,attr))*100);
}else{
icur=parseInt(getStyle(obj,attr));
}
speed=(json[attr]-icur)/10;
speed= speed>0?Math.ceil(speed):Math.floor(speed);
if(attr=="opacity"){
obj.style.filter="alpha(opacity:"+(icur+speed)+")";
obj.style.opacity=(icur+speed)/100;
}else{
obj.style[attr]=icur+speed+"px";
}
if(icur!=json[attr]){
flag=false;
}
if(flag){
clearInterval(obj.timer);
if(fn){
fn();
}
}
}
},30)
}