参考网址:http://www.discuz.net/thread-265541-1-1.html
<html>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" οnlοad="init_srolltext();" bgcolor="#fafafa">
<div id="icefable1">
<table>
<tr><td>
<!--下面为滚动显示的内容,可以用图片框或文本框替换,如<img src="..." height="164" width="251" border="0">-->
<font color=#3A5FCD size=2 face=黑体>【名言警句】一个人最伤心的事情无过于良心的死灭。 —— 郭沫若</font>
</td></tr></table>
<!--这里产生了间隙-->
<table>
<tr><td>
<font color=#0000FF size=2 face=黑体>【名言警句】不要慨叹生活底痛苦!---慨叹是弱者...... —— 高尔基</font>
</td></tr></table>
<table >
<tr><td>
<font color=#8B0A50 size=2 face=黑体>【名言警句】希望是附丽于存在的,有存在,便有希望,有希望,便是光明。 —— 鲁迅</font>
</td></tr></table>
</div>
<script type="text/javascript" language="javascript">
marqueesHeight=24; //因为有间隙存在,这里的高度一定要设置的比图片框或文字框的高度要大,否则将
//无法连续滚动(如上文若为<img src="..." height="164" width="251" border="0">的图片框时,这里一
//定要设置的比164要大,这里因为没有文字框或图片框,所以才设置为24)
stopscroll=false;
with(icefable1){
style.width=0;
style.height=marqueesHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
οnmοuseοver=new Function("stopscroll=true");
οnmοuseοut=new Function("stopscroll=false");
}
preTop=0; currentTop=marqueesHeight; stoptime=0;
icefable1.innerHTML+=icefable1.innerHTML;
function init_srolltext(){
icefable1.scrollTop=0;
setInterval("scrollUp()",20);
}init_srolltext();
function scrollUp(){
if(stopscroll==true) return;
currentTop+=1;
if(currentTop==(marqueesHeight+1))
{
stoptime+=1;
currentTop-=1;
if(stoptime==300) //停留时间设置为300秒
{
currentTop=0;
stoptime=0;
}
}
else {
preTop=icefable1.scrollTop;
icefable1.scrollTop+=1; //scrollTop是图片框的高度,达到scrollTop以后再增加1也还是scrollTop了
//(测试出来的结果)
if(preTop==icefable1.scrollTop){
icefable1.scrollTop=marqueesHeight;
icefable1.scrollTop+=1;
}
}
}
</script></body></html>
ps:对参考资料中的原文做了一点点的修改,所以设定为了原创。以此文纪念和感谢BX对此项知识做出的贡献,要知道为了那个marqueesHeight的设置,我和BX搞到了凌晨,而且还是在寒冷的冬夜,没吃晚饭的冬夜:-((。最后郑重声明:本文仅供个人学习使用。