日期:2014-05-16 浏览次数:20419 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="zh"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <script type="text/javascript"> window.onload = function(){ var speed=30; 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(){setInterval(Marquee,speed)} } </script> </head> <body> <div id="demo" style=" overflow:hidden; width:640px; height:240px;"> <div id="demo1"> <img src="01.jpg" /> <img src="02.jpg" /> <img src="03.jpg" /> </div> <div id="demo2"></div> </div> </body> </html>
------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="zh"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <script type="text/javascript"> window.onload = function(){ var speed=30; demo2.innerHTML=demo1.innerHTML; var MyMar=setInterval(Marquee,speed) demo.onmouseover=function(){clearInterval(MyMar)} demo.onmouseout=function(){setInterval(Marquee,speed)} } function Marquee() { if(demo2.offsetTop-demo.scrollTop<=0) { demo.scrollTop-=demo1.offsetHeight; } else { demo.scrollTop++; } } </script> </head> <body> <div id="demo" style=" overflow:hidden; width:640px; height:240px;"> <div id="demo1"> <img src="01.jpg" /> <img src="02.jpg" /> <img src="03.jpg" /> </div> <div id="demo2"></div> </div> </body> </html>