任意值运动怎么俺写出来的代码不能兼容IE ?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{margin: 0;padding: 0;}
div{width: 200px;height: 100px;background: yellow;margin-bottom: 20px;border: 4px solid #000;opacity: .3;}
</style>
<script type="text/javascript">
window.onload=function(){
var div=document.getElementsByTagName('div');
for(var i = 0; i<div.length; i++ ){
div[i].timer=null; //貌似可以不写
div[i].onmouseover=function(){
starMove(this,'opacity',100);
};
div[i].onmouseout=function(){
starMove(this,'opacity',30);
};
}
};
function getStyle(obj,attr){
if(obj.currenStyle){
return obj.currenStyle[attr];
}else{
return getComputedStyle(obj,false)[attr];
}
}
function starMove(obj,attr,iTarget){
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var icur = 0;
if(attr=='opacity'){
icur=Math.round(parseFloat(getStyle(obj,attr))*100);
}else{
icur=parseInt(getStyle(obj,attr));
}
var speed=(iTarget-icur)/10;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(icur==iTarget){
clearInterval(obj.timer);
}else{
if(attr == 'opacity'){
obj.style.filter='alpha(opacity:'+(icur + speed)+')'
obj.style.opacity=(icur+speed)/100;
}else{
obj.style[attr]=icur+speed+'px';
}
}
},30)
}
</script>
</head>
<body>
<div></div>
<div></div>
<div></div>
</body>
</html>