分享

html,js 文字无缝向上滚动

 红尘精灵 2011-07-18

<html>
<head>
<title>掌股专家——财富在线</title>
</head>
<body><DIV id=div_onlineService><A href="javascript:"></A><BR><BR><A
href="javascript:">2011-5-18 11:20:11   叶女士   问:  股市导航软件多少钱</A><BR><BR><A
href="javascript:">管理员回复:你好,我们股市导航软件有多个版本,适合于不同需求的投资者,具体您可以来电021-33197979向销售人员咨询。 </A><BR><BR><A
href="javascript:">2010-5-25 11:20:11   小股民   问:  你公司在哪,叫什么公司? </A><BR><BR></DIV>
<SCRIPT language=JavaScript>

div_onlineServiceHeight=200;
stopscroll=false;

with(div_onlineService){
  style.width=0;
  style.height=div_onlineServiceHeight;
  style.overflowX="visible";
  style.overflowY="hidden";
  noWrap=true;
  onmouseover=new Function("stopscroll=true");
  onmouseout=new Function("stopscroll=false");
}
document.write('<div id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>');

preTop=0; currentTop=0;

function init(){
  templayer.innerHTML="";
  while(templayer.offsetHeight<div_onlineServiceHeight){
    templayer.innerHTML+=div_onlineService.innerHTML;
  }
  div_onlineService.innerHTML=templayer.innerHTML+templayer.innerHTML;
  setInterval("scrollUp()",20);
}
document.body.onload=init;

function scrollUp(){
  if(stopscroll==true) return;
  preTop=div_onlineService.scrollTop;
  div_onlineService.scrollTop+=1;
  if(preTop==div_onlineService.scrollTop){
    div_onlineService.scrollTop=templayer.offsetHeight-div_onlineServiceHeight;
    div_onlineService.scrollTop+=1;
  }
}
</SCRIPT>

</body>
</html>

————————————————————————————————————————————————

注:无法实现在固定大小的div中,向上滚动;

简单点,可以在div中加table。


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约