关于运动框架的问题
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
div{
width:200px;
height:170px;
background:#0C6;
border:#999 solid 3px;
filter:alpha(opacity:30);
opacity:0.3;}
</style>
<script type="text/javascript" src="model.js">
window.onload=function(){
var box=document.getElementById('div1');
box.onmouseover=function(){
startmove(box,'width',400)
}
}
</script>
</head>
<body>
<div id="div1"></div>
</body>
</html>
------------------------------------------------------------------------
function getStyle(obj,attr){
if(obj.style.currentStyle)
return obj.currentStyle[attr];
else
return getComputedStyle(obj,false)[attr];
}
function startmove(obj,attr,itarget){
clearInterval(obj.timer);
obj.timer=setInterval(function()
{
var speed,currentnum=0;
if(attr=='opacity')
currentnum=Math.round(parseFloat(getStyle(obj,attr))*100);
else
currentnum=parseInt(getStyle(obj,attr));
speed=(itarget-currentnum)/8;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(currentnum==itarget)
clearInterval(obj.timer);
else{
if(attr=='opacity'){
obj.style.filter='alpha:(opacity:'+currentnum+speed+')';
obj.style.opacity=(currentnum+speed)/100;}
else
obj.style[attr]=currentnum+speed+'px';
}
},20)
}
我的代码,运行不出结果,也没错误,这是咋回事?