javascript代码:
<script language="javascript">
articleHeight=140;
stopscrolla=false;
article1.scrollTop=0; with(article1){
style.width=0;
style.height=articleHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
onmouseover=new Function("stopscrolla=true");
onmouseout=new Function("stopscrolla=false");
} preTopa=0; currentTopa=0; stoptimea=0; function init_srolltext1(){
article2.innerHTML="";
article2.innerHTML+=article1.innerHTML;
article1.innerHTML=article2.innerHTML+article2.innerHTML;
setInterval("scrollUp1()",50);
}
function scrollUp1(){
if(stopscrolla==true) return;
currentTopa+=1;
if(currentTopa==140)
{
stoptimea+=1;
currentTopa-=1;
if(stoptimea==1)
{
currentTopa=0;
stoptimea=0;
}
}
else {
preTopa=article1.scrollTop;
article1.scrollTop+=1;
if(preTopa==article1.scrollTop){
article1.scrollTop=article2.offsetHeight-articleHeight;
article1.scrollTop+=1;
}
} }
init_srolltext1();
</script>
<script language="javascript">
articleHeight=140;
stopscrolla=false;
article1.scrollTop=0; with(article1){
style.width=0;
style.height=articleHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
onmouseover=new Function("stopscrolla=true");
onmouseout=new Function("stopscrolla=false");
} preTopa=0; currentTopa=0; stoptimea=0; function init_srolltext1(){
article2.innerHTML="";
article2.innerHTML+=article1.innerHTML;
article1.innerHTML=article2.innerHTML+article2.innerHTML;
setInterval("scrollUp1()",50);
}
function scrollUp1(){
if(stopscrolla==true) return;
currentTopa+=1;
if(currentTopa==140)
{
stoptimea+=1;
currentTopa-=1;
if(stoptimea==1)
{
currentTopa=0;
stoptimea=0;
}
}
else {
preTopa=article1.scrollTop;
article1.scrollTop+=1;
if(preTopa==article1.scrollTop){
article1.scrollTop=article2.offsetHeight-articleHeight;
article1.scrollTop+=1;
}
} }
init_srolltext1();
</script>
<table width="189" border="0" cellSpacing="0" cellPadding="0" align="center">
<tr>
<td>
<div id="article1" style="width:189;">
<TABLE cellSpacing="0" cellPadding="0" width="189" border="0">
<tr>
<td height=140 align=center>
<table width="189" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20" height="24" align="center"><font color="#505050">·</font></td>
<td width="169"><a href="news_article.php?r_id=938" target="_blank">美开发出高叶酸含量转基因...</a></td>
</tr>
<tr>
<td width="20" height="24" align="center"><font color="#505050">·</font></td>
<td width="169"><a href="news_article.php?r_id=937" target="_blank">中国发现调节精子运动新蛋...</a></td>
</tr>
<tr>
<td width="20" height="24" align="center"><font color="#505050">·</font></td>
<td width="169"><a href="news_article.php?r_id=928" target="_blank">猪膀胱粉末让断指奇迹再生</a></td>
</tr>
<tr>
<td width="20" height="24" align="center"><font color="#505050">·</font></td>
<td width="169"><a href="news_article.php?r_id=936" target="_blank">改变不良生活方式积极预防...</a></td>
</tr>
<tr>
<td width="20" height="24" align="center"><font color="#505050">·</font></td>
<td width="169"><a href="news_article.php?r_id=935" target="_blank">国外白领如何减压</a></td>
</tr>
<tr>
<td width="20" height="24" align="center"><font color="#505050">·</font></td>
<td width="169"><a href="news_article.php?r_id=934" target="_blank">上班族的新三件事</a></td>
</tr>
<tr>
<td width="20" height="24" align="center"><font color="#505050">·</font></td>
<td width="169"><a href="news_article.php?r_id=941" target="_blank">久用电脑不动易患腿部血栓</a></td>
</tr>
<tr>
<td width="20" height="24" align="center"><font color="#505050">·</font></td>
<td width="169"><a href="news_article.php?r_id=940" target="_blank">英国科学家称人类自然寿命...</a></td>
</tr>
<tr>
<td width="20" height="24" align="center"><font color="#505050">·</font></td>
<td width="169"><a href="news_article.php?r_id=939" target="_blank">以色列研究找到癌细胞分裂...</a></td>
</tr>
</table>
</td>
</tr>
</TABLE>
</div>
<div id="article2" style="position:absolute;z-index:1;visibility:hidden"></div>
</td>
</tr>
</table>
自己分析代码吧
id不要随便改哟~~要改的话就要,e.g:把所有所有的article1替换掉,
<div id="article1" style="width:189;">
aaaa<br>
bbb<br>
adasdf<br>
fqeaqdf<br>
qowe<br>
afsdf<br>
asdf<br>
asdfqwe<br>
fqwefasd<br>
fqwe
</div>
<div id="article2" style="position:absolute;z-index:1;visibility:hidden"></div> <script language="javascript">
articleHeight=140;
stopscrolla=false;
article1.scrollTop=0;
with(article1){
style.width=0;
style.height=articleHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
onmouseover=new Function("stopscrolla=true");
onmouseout=new Function("stopscrolla=false");
} preTopa=0; currentTopa=0; stoptimea=0; function init_srolltext1(){
article2.innerHTML="";
article2.innerHTML+=article1.innerHTML;
article1.innerHTML=article2.innerHTML+article2.innerHTML;
setInterval("scrollUp1()",50);
}
function scrollUp1(){
if(stopscrolla==true) return;
currentTopa+=1;
if(currentTopa==140)
{
stoptimea+=1;
currentTopa-=1;
if(stoptimea==1)
{
currentTopa=0;
stoptimea=0;
}
}
else {
preTopa=article1.scrollTop;
article1.scrollTop+=1;
if(preTopa==article1.scrollTop){
article1.scrollTop=article2.offsetHeight-articleHeight;
article1.scrollTop+=1;
}
} }
init_srolltext1();
</script>