图片上无缝滚动
向上滚动
<script> <br><!-- <BR>var speed=10; //数字越大速度越慢 <BR>var tab=document.getElementById("demo"); <BR>var tab1=document.getElementById("demo1"); <BR>var tab2=document.getElementById("demo2"); <BR>tab2.innerHTML=tab1.innerHTML; //克隆demo1为demo2 <BR>function Marquee(){ <BR>if(tab2.offsetTop-tab.scrollTop<=0)//当滚动至demo1与demo2交界时 <BR>tab.scrollTop-=tab1.offsetHeight //demo跳到最顶端 <BR>else{ <BR>tab.scrollTop++ <BR>} <BR>} <BR>var MyMar=setInterval(Marquee,speed); <BR>tab.onmouseover=function() {clearInterval(MyMar)};//鼠标移上时清除定时器达到滚动停止的目的 <BR>tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};//鼠标移开时重设定时器 <BR>--> <br></script>
图片下无缝滚动
向下滚动
<script> <BR><!-- <BR>var speed=10; //數字越大速度越慢<BR>var tab=document.getElementById("demo"); <BR>var tab1 =document.getElementById("demo1"); <BR>var tab2=document.getElementById("demo2"); <BR>tab2.innerHTML=tab1.innerHTML; //複製demo1為demo2 <BR>tab.scrollTop =tab. .scrollHeight <BR>function Marquee(){ <BR>if(tab1.offsetTop-tab.scrollTop>=0)//當捲動至demo1與demo2交界時<BR>tab.scrollTop =tab2.offsetHeight //demo2交界時<BR>tab.scrollTop =tab2.offsetHeight //demo到最頂端<BR>else{ <BR>tab.scrollTop-- <BR>} <BR>} <BR>var MyMar=setInterval(Marquee,speed); <BR>tab.onmouseover=function() {clearInterval() {clearInterval( MyMar)};//滑鼠移上時清除定時器達到滾動停止的目的<BR>tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};//滑鼠移開時重置時器<BR>--> <BR></script>
圖片左無縫滾動
向左捲動
<script> <BR><!-- <BR>var speed=10; //數字越大速度越慢<BR>var tab=document.getElementById("demo"); <BR>var tab1=document.getElementById("demo1"); <BR>var tab2=document.getElementById("demo2"); <BR>tab2=document.getElementById("demo2"); <BR>tab2. innerHTML=tab1.innerHTML; <BR>function Marquee(){ <BR>if(tab2.offsetWidth-tab.scrollLeft<=0) <BR>tab.scrollLeft-=tab1.offsetWidth <BR>else .scrollLeft ; <BR>} <BR>} <BR>var MyMar=setInterval(Marquee,speed); <BR>tab.onmouseover=function() {clearInterval(MyMar)}; <BR>tab.onmouseout=function( ) {MyMar=setInterval(Marquee,speed)}; <BR>--> <BR></script>
圖片右無縫滾動
向右捲動
<script> <BR><!-- <BR>var speed=10; //數字越大速度越慢<BR>var tab=document.getElementById("demo"); <BR>var tab1=document.getElementById("demo1"); <BR>var tab2=document. getElementById("demo2"); <BR>tab2.innerHTML=tab1.innerHTML; <BR>function Marquee(){ <BR>if(tab.scrollLeft<=0) <BR>tab.scrollLeft =tab2. >else{ <BR>tab.scrollLeft-- <BR>} <BR>} <BR>var MyMar=setInterval(Marquee,speed); <BR>tab.onmouseover=function() {clearInterval(MyMar)}; 🎜>tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)}; <BR>--> <BR></script>