• js带箭头左右翻动控制


    <!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=gb2312" />
    <title>带左右箭头切换的自动滚动图片JS特效</title>
    <style type="text/css">
    *{margin:0px; padding:0px;}
    img{border:0;}
    a{text-decoration:none;}
    a:hover{text-decoration:underline;}
    li{list-style:none; list-style-image:none; list-style-type:none;}
    .rollBox{width:938px;overflow:hidden;padding:0;margin:0 auto; background-color:#F8F8F8;}
    .rollBox .LeftBotton{height:29px;width:19px;background:url(http://www.huizhou.cn/webfile/2012/8/21/images/left.jpg) no-repeat;overflow:hidden;float:left;display:inline;margin:44px 0 0 0;cursor:pointer;}
    .rollBox .RightBotton{height:29px;width:19px;background:url(http://www.huizhou.cn/webfile/2012/8/21/images/right.jpg) no-repeat right 0;overflow:hidden;float:left;display:inline;margin:44px 0 0 0;cursor:pointer;}
    .rollBox .Cont{width:900px;overflow:hidden;float:left;}
    .rollBox .ScrCont{width:10000000px;}
    .rollBox .Cont .pic{width:172px;float:left;text-align:center; margin-right:10px;}
    .rollBox .Cont .pic img{display:block; margin-bottom:7px;}
    .rollBox .Cont .pic p,.rollBox .Cont .pic p a{font:normal 12px/20px "宋体";color:#777;}
    .rollBox #List1,.rollBox #List2{float:left;}
    .rollBox .Cont .pic p span,.rollBox .Cont .pic p span a{color:#E30074;}
    </style>
    </head>
    
    <body>
    
    <div class="rollBox">
    
         <div class="LeftBotton" onmousedown="ISL_GoUp()" onmouseup="ISL_StopUp()" onmouseout="ISL_StopUp()"></div>
    
         <div class="Cont" id="ISL_Cont">
    
          <div class="ScrCont">
    
           <div id="List1">
    
            <!-- 图片列表 begin -->
        
        
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_12.htm" target="_blank"><img src="./201208/W020120821628900935063.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_12.htm" target="_blank" target='_blank'>《粽香四溢》</a></span></p>
                <p>惠城区 刘心瑜 刘千里</p>
            </div> 
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_11.htm" target="_blank"><img src="./201208/W020120821628548909706.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_11.htm" target="_blank" target='_blank'>《正月十五元宵快乐》</a></span></p>
                <p>龙门县 龙城三小 张静瑜</p>
            </div> 
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_10.htm" target="_blank"><img src="./201208/W020120821628231710339.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_10.htm" target="_blank" target='_blank'>《五月端午节》</a></span></p>
                <p>惠城区南雁 林晓红</p>
            </div> 
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_9.htm" target="_blank"><img src="./201208/W020120821627724689770.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_9.htm" target="_blank" target='_blank'>《清明节》</a></span></p>
                <p>龙门县 方欣仪</p>
            </div> 
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_8.htm" target="_blank"><img src="./201208/W020120821627398439764.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_8.htm" target="_blank" target='_blank'>《七夕》</a></span></p>
                <p>龙门县 钟晴</p>
            </div> 
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_7.htm" target="_blank"><img src="./201208/W020120821627020930286.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_7.htm" target="_blank" target='_blank'>《可爱的祖国 》</a></span></p>
                <p>仲恺区 罗灵芳</p>
            </div> 
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_6.htm" target="_blank"><img src="./201208/W020120821626694680140.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_6.htm" target="_blank" target='_blank'>《欢度元宵》</a></span></p>
                <p>惠阳区秋长 陈茵茵</p>
            </div> 
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_5.htm" target="_blank"><img src="./201208/W020120821626312815924.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_5.htm" target="_blank" target='_blank'>《父爱如山》</a></span></p>
                <p>惠城区 陈春雪</p>
            </div> 
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_4.htm" target="_blank"><img src="./201208/W020120821625913286107.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_4.htm" target="_blank" target='_blank'>《端午节快乐》</a></span></p>
                <p>惠东县 刘玉洁</p>
            </div> 
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_2.htm" target="_blank"><img src="./201208/W020120821625539531902.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_2.htm" target="_blank" target='_blank'>《端午节》</a></span></p>
                <p>惠城区河南岸中心小学 冯沁怡</p>
            </div> 
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_1.htm" target="_blank"><img src="./201208/W020120821624886719505.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_1.htm" target="_blank" target='_blank'>《端午节》</a></span></p>
                <p>惠城区 丁南洋</p>
            </div> 
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_3.htm" target="_blank"><img src="./201208/W020120821624443904557.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485_3.htm" target="_blank" target='_blank'>《端午节》</a></span></p>
                <p>惠阳区良井 陈泳宏</p>
            </div> 
               
            <div class="pic">
                <a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485.htm" target="_blank"><img src="./201208/W020120821624147819546.jpg" width=172 height=124/></a>
                <p><span><a href="http://www.huizhou.cn/zt2012/jrxb/zpj/201208/t20120821_754485.htm" target="_blank" target='_blank'>《春之歌》</a></span></p>
                <p>博罗县 曾瑞芳</p>
            </div> 
                  
    
    
            <!-- 图片列表 end -->
    
           </div>
    
           <div id="List2"></div>
    
          </div>
    
         </div>
    
         <div class="RightBotton" onmousedown="ISL_GoDown()" onmouseup="ISL_StopDown()" onmouseout="ISL_StopDown()"></div>
    
        </div>
    
       </div>
    
    
    
    <script language="javascript" type="text/javascript">
    
    <!--//--><![CDATA[//><!--
    
    //图片滚动列表 5icool.org
    
    var Speed = 0; //速度(毫秒)
    
    var Space = 5; //每次移动(px)
    
    var PageWidth = 182; //翻页宽度
    
    var fill = 0; //整体移位
    
    var MoveLock = false;
    
    var MoveTimeObj;
    
    var Comp = 0;
    
    var AutoPlayObj = null;
    
    GetObj("List2").innerHTML = GetObj("List1").innerHTML;
    
    GetObj('ISL_Cont').scrollLeft = fill;
    
    GetObj("ISL_Cont").onmouseover = function(){clearInterval(AutoPlayObj);}
    
    GetObj("ISL_Cont").onmouseout = function(){AutoPlay();}
    
    AutoPlay();
    
    function GetObj(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}}
    
    function AutoPlay(){ //自动滚动
    
     clearInterval(AutoPlayObj);
    
     AutoPlayObj = setInterval('ISL_GoDown();ISL_StopDown();',10000000000); //间隔时间
    
    }
    
    function ISL_GoUp(){ //上翻开始
    
     if(MoveLock) return;
    
     clearInterval(AutoPlayObj);
    
     MoveLock = true;
    
     MoveTimeObj = setInterval('ISL_ScrUp();',Speed);
    
    }
    
    function ISL_StopUp(){ //上翻停止
    
     clearInterval(MoveTimeObj);
    
     if(GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0){
    
      Comp = fill - (GetObj('ISL_Cont').scrollLeft % PageWidth);
    
      CompScr();
    
     }else{
    
      MoveLock = false;
    
     }
    
     AutoPlay();
    
    }
    
    function ISL_ScrUp(){ //上翻动作
    
     if(GetObj('ISL_Cont').scrollLeft <= 0){GetObj('ISL_Cont').scrollLeft = GetObj('ISL_Cont').scrollLeft + GetObj('List1').offsetWidth}
    
     GetObj('ISL_Cont').scrollLeft -= Space ;
    
    }
    
    function ISL_GoDown(){ //下翻
    
     clearInterval(MoveTimeObj);
    
     if(MoveLock) return;
    
     clearInterval(AutoPlayObj);
    
     MoveLock = true;
    
     ISL_ScrDown();
    
     MoveTimeObj = setInterval('ISL_ScrDown()',Speed);
    
    }
    
    function ISL_StopDown(){ //下翻停止
    
     clearInterval(MoveTimeObj);
    
     if(GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0 ){
    
      Comp = PageWidth - GetObj('ISL_Cont').scrollLeft % PageWidth + fill;
    
      CompScr();
    
     }else{
    
      MoveLock = false;
    
     }
    
     AutoPlay();
    
    }
    
    function ISL_ScrDown(){ //下翻动作
    
     if(GetObj('ISL_Cont').scrollLeft >= GetObj('List1').scrollWidth){GetObj('ISL_Cont').scrollLeft = GetObj('ISL_Cont').scrollLeft - GetObj('List1').scrollWidth;}
    
     GetObj('ISL_Cont').scrollLeft += Space ;
    
    }
    
    function CompScr(){
    
     var num;
    
     if(Comp == 0){MoveLock = false;return;}
    
     if(Comp < 0){ //上翻
    
      if(Comp < -Space){
    
       Comp += Space;
    
       num = Space;
    
      }else{
    
       num = -Comp;
    
       Comp = 0;
    
      }
    
      GetObj('ISL_Cont').scrollLeft -= num;
    
      setTimeout('CompScr()',Speed);
    
     }else{ //下翻
    
      if(Comp > Space){
    
       Comp -= Space;
    
       num = Space;
    
      }else{
    
       num = Comp;
    
       Comp = 0;
    
      }
    
      GetObj('ISL_Cont').scrollLeft += num;
    
      setTimeout('CompScr()',Speed);
    
     }
    
    }
    
    //--><!]]>
    
    </script>
    </body>
    
    </html>
  • 相关阅读:
    mysql数据引擎
    R语言入门
    springboot整合springmvc、mybatis
    svn搭建和配置
    UML常用图的几种关系的总结
    cookies和session机制
    Java总结篇系列:Java多线程(三)
    Java总结篇系列:Java多线程(一)
    Java总结篇系列:Java多线程(二)
    restframework之认证
  • 原文地址:https://www.cnblogs.com/zywf/p/4669796.html
Copyright © 2020-2023  润新知