JS文件中的代码
function scrollUp(object, perHeight, count, speed)
{
var stopScroll = false;
var preTop = 0;
var curTop = 0;
var stopTime = 0;
with(eval(object)){
innerHTML += eval(object).innerHTML;
style.height = perHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
onmouseover=new Function("stopScroll=true");
onmouseout=new Function("stopScroll=false");
}
eval(object).scrollTop = 0;
curTop = 0;
setInterval (
function(){
if (stopScroll == true) return;
curTop ++;
if (curTop == (perHeight+1))
{
stopTime ++;
curTop --;
if (stopTime == 80)
{
stopTime = 0;
curTop = 0;
}
}
else
{
preTop = eval(object).scrollTop;
eval(object).scrollTop ++;
if (eval(object).scrollTop == (perHeight*count))
{
eval(object).scrollTop = 0;
preTop = 0;
}
}
}
, speed);
}
function scroll_init(object, perHeight, count, speed)
{
var stopScroll = false;
var preTop = 0;
var curTop = 0;
var stopTime = 0;
with(eval(object)){
innerHTML += eval(object).innerHTML;
style.height = perHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
onmouseover=new Function("stopScroll=true");
onmouseout=new Function("stopScroll=false");
}
eval(object).scrollTop = 0;
curTop = 0;
}
用法
<script language="javascript">scrollUp('divArtist', 294, 2, 40);</script>
scroll_init函数可以不用,不过用的空间速度不均,大运算量结果可能位置有些偏移,在onload或其它地方先init一下,最后在实行scrollUp,可以消除偏移
网站被关了,注册了n次,头疼