<!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=gb2312" />
<title>简易购物车</title>
</head>
<body>
<script type="text/JavaScript">
document.write('<div id="picrun" style="height:68px;overflow:hidden;width:290px;font-size:0">');
document.write('<span style="height:68px;overflow:hidden;width:290px;"><a id="img1" href="@[ad_link1]"><img src="http://i1.6.cn/7a/60/h450081244163854.jpg" border="0px" width="290px" height="68px"/></a></span>');
document.write('<span style="height:68px;overflow:hidden;width:290px;"><a id="img" href="@[ad_link2]"><img src="http://i2.6.cn/a5/e5/n948391244539267.jpg" border="0px" width="290px" height="68px"/></a></span>');
document.write('<span style="height:68px;overflow:hidden;width:290px;"><a id="img3" href="@[ad_link3]"><img src="http://i3.6.cn/f9/8a/k837331244192528.jpg" border="0px" width="290px" height="68px"/></a></span>');
document.write('</div>')var oMarquee = document.getElementById("picrun"); //滚动对象
var iLineHeight = 68; //单行高度,像素
var iLineCount = 3; //实际行数
var index=0;
function run() {
    oMarquee.scrollTop += Math.ceil(((index+1)*iLineHeight-oMarquee.scrollTop)*0.001);
    if ( oMarquee.scrollTop == iLineCount * iLineHeight ){
           oMarquee.scrollTop = index = 0;          
    }
    var speed = 0;
    if ( oMarquee.scrollTop % iLineHeight == 0 ) {
        speed=1000;if(oMarquee.scrollTop!=0)index++;
    }
    window.setTimeout( "run()", speed);
}
oMarquee.innerHTML += oMarquee.innerHTML;
window.setTimeout( "run()", 1000 );
</script></body>
</html>

解决方案 »

  1.   

    run就是滚动效果函数方法啊~·你这个不是上下滚动文字吗
      

  2.   

     oMarquee.scrollTop += Math.ceil(((index+1)*iLineHeight-oMarquee.scrollTop)*0.001);主要是这一段。。他滚动的不是图片么。。为什么是DIV滚动。
      

  3.   


    就是用最外层的div的高度 来实现滚动效果的
      

  4.   

    你把<div id="picrun" style="height:68px;overflow:hidden;width:290px;font-size:0">
    改为<div id="picrun" style="height:68px;overflow:scroll;width:290px;font-size:0">
    然后看下效果就知道了。
    设置div的滚动条滚动。