//scrollBodyId:??String 內部滾動div的id
//scrollBoxId:??String 外面限制div的id
//showHeight:??Int 限制顯示高度
//showWidth:??Int 限制顯示寬度
//lineHeight:??Int 每行的高度
//stopTime:????Int 間隔停止的時間(毫秒)
//speed:????Int 滾動速度(毫秒,越小越快)
//var sample = new ScrollObj("scroollBody","scroollBox",36,300,19,50,50);
var ScrollObj = function(scrollBodyId,scrollBoxId,showHeight,showWidth,lineHeight,stopTime,speed) {
??this.obj = document.getElementById(scrollBodyId);
??this.box = document.getElementById(scrollBoxId);
??
??this.style = this.obj.style;
??this.defaultHeight = this.obj.offsetHeight;
??
??this.obj.innerHTML += this.obj.innerHTML;
??this.obj.style.position = "relative";
??
??this.box.style.height = showHeight;
??this.box.style.width = showWidth;
??this.box.style.overflow = "hidden";
??
??this.scrollUp = doScrollUp;
??this.stopScroll = false;
??
??this.curLineHeight = 0;
??this.lineHeight = lineHeight;
??this.curStopTime = 0;
??this.stopTime = stopTime;
??this.speed = speed;
??this.style.top = lineHeight;
??this.object = scrollBodyId + "Object";
??eval(this.object + "=this");
??setInterval(this.object+".scrollUp()",speed);
??this.obj.onmouseover=new Function(this.object+".stopScroll=true");
??this.obj.onmouseout=new Function(this.object+".stopScroll=false");
}
function doScrollUp(){
??if( this.stopScroll == true )
????return;
???this.curLineHeight += 1;
???if( this.curLineHeight >= this.lineHeight ){
?????this.curStopTime += 1;
?????if( this.curStopTime >= this.stopTime ){
???????this.curLineHeight = 0;
???????this.curStopTime = 0;
?????}
???}
??else{ ??
?? ??this.style.top = parseInt(this.style.top) - 1;
?? ??if( -parseInt(this.style.top) >= this.defaultHeight ){
?? ??this.style.top = 0;
?? ??}
???}
}
凡是有該標志的文章,都是該blog博主Caoer(草兒)原創,凡是索引、收藏
、轉載請注明來處和原文作者。非常感謝。