辰峰微网

无缝隙滚动代

Jack·高峰 2745 阅读
文章摘要
横向

<div id="hot" style="overflow: hidden; width: 100%; color: #ffffff">

                  <table cellSpacing="0" cellPadding="0" align="left" border="0">

            ...
当前字体大小 15px
12px 50px
横向

<div id="hot" style="overflow: hidden; width: 100%; color: #ffffff">

                  <table cellSpacing="0" cellPadding="0" align="left" border="0">

                    <tbody>

                    <tr>

                      <td id="divhot" valign="top">

                    内容                      </td>

                      <td id="hot2" valign="top">&nbsp;</td></tr></tbody></table></div>         

                    <script type="text/javascript">

                    var hot = document.getElementById("hot");

                     var hot1 = document.getElementById("divhot");

                     var hot2 = document.getElementById("hot2");

                     var pause=0;         

                     hot2.innerHTML=hot1.innerHTML;

                     function scrollMl()

                     {

                        if(hot2.offsetWidth-hot.scrollLeft<=0)

                        {

                            hot.scrollLeft-=hot1.offsetWidth;

                        }

                        else

                        {

                            hot.scrollLeft++;

                        }

                     }

                     function scrollMr()

                     {

                        if(hot.scrollLeft<=0)

                        {

                            hot.scrollLeft+=hot2.offsetWidth;

                        }

                        else

                        {

                            hot.scrollLeft--;

                        }

                     }                      

                    var hottime;

                    function doLeft()

                    {

                        clearInterval(hottime);

                         hottime=setInterval(scrollMl,20);

                    }

                    function doRight()

                    {

                        clearInterval(hottime);

                        hottime=setInterval(scrollMr,20);

                    }

                    hot.onmouseover=function(){clearInterval(hottime);}

                    hot.onmouseout=function(){hottime=setInterval(scrollMl,20);}

                    doRight();     

                    </script>
分享到:
收藏

    发表评论