關(guān)于運(yùn)動(dòng)框架的問題
<!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>無標(biāo)題文檔</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)
}
我的代碼,運(yùn)行不出結(jié)果,也沒錯(cuò)誤,這是咋回事?
2022-03-23
謝謝支持,加油哦!同解,估計(jì)不會(huì),單獨(dú)發(fā)出了,服務(wù)器上有很多多存放太多的文件!
2016-05-17
此問題已解決
2016-05-17
function getStyle(obj,attr){
????if(obj.currentStyle)????//檢測(cè)IE
????????return obj.currentStyle[attr];
????else
????????return getComputedStyle(obj,false)[attr];
}
2016-05-15
f(obj.style.currentStyle)? 有問題~