function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}
else{
return getComputedStyle(obj,null)[attr];
}
}
function mover(){
var box=document.getElementById("box");
box.timer=null;
box.onmouseover=function(){
star(box,"width",400);
}
box.onmouseout=function(){
star(box,"width",200);
}
}
function star(obj,attr,target)
{
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var who=obj.offsetWidth;
// who=parseInt(getStyle(obj,attr));
var speed=(target-who)/8;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(who==target)
{
clearInterval(obj.timer);
}
document.getElementById("id1").innerHTML=who;
document.getElementById("id2").innerHTML=speed;
obj.style[attr]=who+speed+"px";
},30);
}还是395 取整了也没有 代码我一个个对了也没问题 在ie下 可以到达400没有问题 谷歌下就不行?
