不明白为什么,这还是抄袭别人的写法,但是却出问题了,别人的是对的.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<style type="text/css">
#ss{width:130px;height:88px;margin:0 auto;background:#ffffff;overflow: hidden; border:1px solid #000000; position:relative}
#num{ position:absolute; right:5px; bottom:5px;}
#num li{
float: left;
list-style:none;
color: #fff;
text-align: center;
line-height: 16px;
width: 16px;
height: 16px;
font-family: Arial;
font-size: 12px;
cursor: pointer;
margin: 1px;
border: 1px solid #707070;
background-color:#990000;
}
</style>
<body>
<div id='ss'>
<table cellpadding="0" cellspacing="0">
<th><img src="http://img1.qq.com/news/pics/17522/17522502.jpg"/></th>
<th><img src="http://img1.qq.com/news/pics/17515/17515126.jpg"/></th>
<th><img src="http://img1.qq.com/news/pics/17515/17515135.jpg"/></th>
</table>
<ul id='num'>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
<div id='s'></div>
<script>
/////////////////////////////////////////////////////////////////////////////////
var Tween = {
Quart: {
easeOut: function(t,b,c,d){
return -c * ((t=t/d-1)*t*t*t - 1) + b;
}
}
}
/////////////////////////////////////////////////////////////////////////////////function $(Id){return document.getElementById(Id)};
var n = $('ss').getElementsByTagName('th').length;
var w = $('ss').getElementsByTagName('th')[0].offsetWidth;
var i=0,t=110,b=0,c=w,d=60,isleft=true;
function Run(){
if(t<d)
{t++;$('s').innerHTML=$('ss').scrollLeft;$('ss').scrollLeft = Math.round(Tween.Quart.easeOut(t,b,c,d));setTimeout(Run, 10);}
else
{
if(i==0)
{isleft=true,t=0,b=0,c=w;i++;}
else if(i==(n-1))
{isleft=false,t=0,b=(n-1)*w,c=(-1)*w,i=i-1;}
else
{t=0,b=i*w,i=i+(isleft?1:-1);}
setTimeout(Run, 800)
}
};
setTimeout(Run,2000);
</script>
</body>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<style type="text/css">
#ss{width:130px;height:88px;margin:0 auto;background:#ffffff;overflow: hidden; border:1px solid #000000; position:relative}
#num{ position:absolute; right:5px; bottom:5px;}
#num li{
float: left;
list-style:none;
color: #fff;
text-align: center;
line-height: 16px;
width: 16px;
height: 16px;
font-family: Arial;
font-size: 12px;
cursor: pointer;
margin: 1px;
border: 1px solid #707070;
background-color:#990000;
}
</style>
<body>
<div id='ss'>
<table cellpadding="0" cellspacing="0">
<th><img src="http://img1.qq.com/news/pics/17522/17522502.jpg"/></th>
<th><img src="http://img1.qq.com/news/pics/17515/17515126.jpg"/></th>
<th><img src="http://img1.qq.com/news/pics/17515/17515135.jpg"/></th>
</table>
<ul id='num'>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
<div id='s'></div>
<script>
/////////////////////////////////////////////////////////////////////////////////
var Tween = {
Quart: {
easeOut: function(t,b,c,d){
return -c * ((t=t/d-1)*t*t*t - 1) + b;
}
}
}
/////////////////////////////////////////////////////////////////////////////////function $(Id){return document.getElementById(Id)};
var n = $('ss').getElementsByTagName('th').length;
var w = $('ss').getElementsByTagName('th')[0].offsetWidth;
var i=0,t=110,b=0,c=w,d=60,isleft=true;
function Run(){
if(t<d)
{t++;$('s').innerHTML=$('ss').scrollLeft;$('ss').scrollLeft = Math.round(Tween.Quart.easeOut(t,b,c,d));setTimeout(Run, 10);}
else
{
if(i==0)
{isleft=true,t=0,b=0,c=w;i++;}
else if(i==(n-1))
{isleft=false,t=0,b=(n-1)*w,c=(-1)*w,i=i-1;}
else
{t=0,b=i*w,i=i+(isleft?1:-1);}
setTimeout(Run, 800)
}
};
setTimeout(Run,2000);
</script>
</body>
应该是一开始就错了!~