<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无缝向左滑动代码</title>
<style>
#demo img{ width:100px; height:120px; padding:10px 0;}
</style>
</head>

<body>
<div id="demo" style="overflow:hidden;height:130px;width:232px;background:#f4f4f4;color:#ffffff">
    <table align=left cellpadding=0 cellspace=0 border=0>
          <tr>
          <td id="demo1" valign=top>
              <table cellpadding="0" cellspacing="0">
                <tr>
                   <td><img src="1.jpg"></td>
                   <td> <img src="2.jpg"></td>
                   <td> <img src="3.jpg"></td>
                   <td> <img src="4.jpg"></td>
                   <td> <img src="5.jpg"></td>
             </tr>
             </table>
         </td>
         <td id="demo2" valign=top> </td>
         </tr>
   </table>

</div>
  <script>
  var speed=30;
  var demo=document.getElementById("demo");
  var demo2=document.getElementById("demo2");
  var demo1=document.getElementById("demo1");
  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>
</body>
</html>

posted on 2011-11-10 23:25  zcjnever  阅读(221)  评论(0编辑  收藏  举报