当前位置:asp编程网>技术教程>Javascript教程>  正文

文字向上移动

2007-11-14 17:33:20   来源:网络    作者:佚名   浏览量:1851   收藏
<style>
.black12 {font-size:12px;color:#000000;}
a.black12:link {font-size:12px;color:#000000;text-decoration:none;}
a.black12:visited {font-size:12px;color:#000000;text-decoration:none;}
a.black12:hover {font-size:12px;color:#000000;text-decoration:underline;}
a.black12line:link {font-size:12px;color:#000000;text-decoration:underline;}
a.black12line:visited {font-size:12px;color:#000000;text-decoration:underline;}
a.black12line:hover {font-size:12px;color:#000000;text-decoration:none;}
</style>
<TABLE border=1 width=200>
<TR>
 <TD>
<div id="marquees">
<div class="details">
<a href='http://www.sina.com.cn' target='_blank' class="black12 blackDot"><li>新浪</li></a>
<a href='http://www.baidu.com' target='_blank' class="black12 blackDot"><li>百度</li></a>
<a href='http://www.google.com' target='_blank' class="black12 blackDot"><li>google</li></a>
<a href='http://www.yahoo.com.cn' target='_blank' class="black12 blackDot"><li>雅虎</li></a>
<a href='http://www.163.com' target='_blank' class="black12 blackDot"><li>网易</li></a>
<a href='http://www.sohu.com' target='_blank' class="black12 blackDot"><li>搜狐</li></a>
</div>
</div>
</TD>
</TR>
</TABLE>
<script language="javascript">
marqueesHeight=100;
stopscroll=false;
with(document.getElementById("marquees")){
 style.width=0;
 style.height=marqueesHeight;
 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(){
document.getElementById("templayer").innerHTML="";
while(document.getElementById("templayer").offsetHeight<marqueesHeight){
document.getElementById("templayer").innerHTML+=document.getElementById("marquees").innerHTML;
}
document.getElementById("marquees").innerHTML=document.getElementById("templayer").innerHTML+document.getElementById("templayer").innerHTML;
setInterval("scrollUp()",30);
}
document.body.onload=init;

function scrollUp(){
if(stopscroll==true) return;
preTop=document.getElementById("marquees").scrollTop;
document.getElementById("marquees").scrollTop+=1;
if(preTop==document.getElementById("marquees").scrollTop){
document.getElementById("marquees").scrollTop=document.getElementById("templayer").offsetHeight-marqueesHeight;
document.getElementById("marquees").scrollTop+=1;
}
}
</script>

关于我们-广告合作-联系我们-积分规则-网站地图

Copyright(C)2013-2017版权所属asp编程网