JS无缝文字滚动(兼容各大浏览器)

<style>
*{margin:0px;padding:0px;border:0px;}
body{font-size:12px}
#demo1{
height:auto;
text-align:left;
}
#demo2{
height:auto;
text-align:left;
}
#demo1 li{
list-style-type:none;
height:22px;
background:url() no-repeat left center;
text-align:left;
text-indent:15px;
}
#demo2 li{
list-style-type:none;
height:22px;
background:url() no-repeat left center;
text-align:left;
text-indent:15px;
}
</style>
</head>
<body>
<div id="demo" style="overflow:hidden;height:50px;width:280px;">
<ul id="demo1">
<li><a href="#" target="_blank">1</a></li>
<li><a href="#" target="_blank">2</a></li>
<li><a href="#" target="_blank">3</a></li>
<li><a href="#" target="_blank">4</a></li>
<li><a href="#" target="_blank">5</a></li>
<li><a href="#" target="_blank">6</a></li>
<li><a href="#" target="_blank">7</a></li>
</ul>
<div id="demo2"></div>
</div>
<script>
var speed=100
var demo=document.getElementById("demo");
var demo2=document.getElementById("demo2");
var demo1=document.getElementById("demo1");
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetTop-demo.scrollTop<=0)
demo.scrollTop-=demo1.offsetHeight
else{
demo.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>

上一篇:android之TextView


下一篇:java – DBunit;对表/列名称的区分大小写的混淆