以下是代码片段: 一开始用的是marquee标签,该方法不能实现无缝滚动,且通不过WEB标准检验,故改用JS实现。但动易2005的系统函数:ShowAnnounce输出代码中有<hr>,向上滚动时水平线也显示出来了,又通过修改语言包(加一个<br />)和添加一个CSS(hr {display: none;})来“去掉”水平线,终于达到了自己预期的效果。 演示:http://www.jzxx.net/ 具体做法如下: 首先打开“Language/Gb2312.xml",找到: <PageChar>个公告</PageChar> <AnnounceErr><![CDATA[<p> 没有公告</p>]]></AnnounceErr> 下面的两行添加"<br />": <AnnounceBody1><![CDATA[<a class=’AnnounceBody1’ href=’#’ onclick="javascript:window.open(’{$strInstallDir}Announce.asp?ChannelID={$ChannelID}&ID={$ID}’, ’newwindow’, ’ <AnnounceBody2><![CDATA[<a class=’AnnounceBody2’ href=’#’ onclick="javascript:window.open(’{$strInstallDir}Announce.asp?ChannelID={$ChannelID}&ID={$ID}’, ’newwindow’, ’ 然后在模板中放置如下代码即可: <style type="text/css"> hr { display: none; } #ann { padding-left: 10px; height: 17px; /*滚动框的高度,可自行调整*/ overflow: hidden; } </style> <div id="ann"> <div id="ann1">{$ShowAnnounce(1,5,false,false,0)}</div> <div id="ann2"></div> </div> <script type="text/javascript"> var articleHeight=20; var stopscrolla=false; var preTopa=0; var currentTopa=0; var stoptimea=0; function init_srolltext1() { ann1.scrollTop=0; with(ann1) { style. style. style.overflowX="visible"; style.overflowY="hidden"; noWrap=true; onmouseover=new Function("stopscrolla=true"); onmouseout=new Function("stopscrolla=false"); } ann2.innerHTML=""; ann2.innerHTML =ann1.innerHTML; ann1.innerHTML=ann2.innerHTML ann2.innerHTML; setInterval("scrollUp1()",50); } function scrollUp1() { if(stopscrolla==true) return; currentTopa =1; if(currentTopa==21) //21为滚动的距离,也可自行调整 { stoptimea =1; currentTopa-=1; if(stoptimea==50) //50为停顿的时间,自行设置 { currentTopa=0; stoptimea=0; } } else { preTopa=ann1.scrollTop; ann1.scrollTop =1; if(preTopa==ann1.scrollTop) { ann1.scrollTop=ann2.offsetHeight-articleHeight; ann1.scrollTop =1; } } } init_srolltext1(); </script> |
新闻热点
疑难解答
图片精选