1.向上滚动
<div id="ntice" style="overflow:hidden;275px; height :196px; margin-top:4px;">
<div id="ntice1" >
<ul>
<li>内容</li>
</ul>
</div>
<div id="ntice2"></div>
</div>
<div id="ntice1" >
<ul>
<li>内容</li>
</ul>
</div>
<div id="ntice2"></div>
</div>
<script language="javascript" type ="text/javascript">
var speed=50
ntice2.innerHTML=ntice1.innerHTML
function Marquee(){
if(ntice2.offsetTop-ntice.scrollTop<=0)
ntice.scrollTop-=ntice1.offsetHeight
else{
ntice.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
ntice.onmouseover=function() {clearInterval(MyMar)}
ntice.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
var speed=50
ntice2.innerHTML=ntice1.innerHTML
function Marquee(){
if(ntice2.offsetTop-ntice.scrollTop<=0)
ntice.scrollTop-=ntice1.offsetHeight
else{
ntice.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
ntice.onmouseover=function() {clearInterval(MyMar)}
ntice.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
2.左滚动
<div id="demo" style="overflow:hidden;850px;height:100px;">
<table>
<tr>
<td id="demo1">
<table >
<tr>
<td>滚动内容</td>
<tr>
</table>
</td>
<td id="demo2"></td>
</tr>
</table>
</div>
<table>
<tr>
<td id="demo1">
<table >
<tr>
<td>滚动内容</td>
<tr>
</table>
</td>
<td id="demo2"></td>
</tr>
</table>
</div>
<script language="JavaScript" type="text/javascript">
var speed=30
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
var speed=30
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>