日期:2014-05-16  浏览次数:20393 次

求一个鼠标点击两边箭头,图片可以左右滑动的js代码?
求一个鼠标点击两边箭头,图片可以左右滑动的js代码?

------解决方案--------------------
探讨
引用:
http://sorgalla.com/projects/jcarousel/examples/static_simple.html

http://sorgalla.com/jcarousel/

就是这样的效果 这为兄弟 如果我要一次显示 6张图片我要在哪里改? 我给你加分

------解决方案--------------------
包裹的DIV的STYLE.LEFT的X坐标改一下就行了,
诸如:VAR X=DIV.STYLE.LEFT
X=X-IMAGE.WIDTH
同时关键点是外围DIV的overflow: hidden
JScript code
JS.Append(" <script type=\"text/javascript\">\n"); 

      JS.Append("var IsPaused=false;\n");
      JS.Append("var pix = 0;\n");
      JS.AppendFormat("var divWidth = {0};\n", _Items.Count * (_ImageWidth + 1));
      JS.AppendFormat("var divVirtualWidth = {0};\n", _NoOfVisibleImages * (_ImageWidth + 1));

      JS.Append("function Start()\n");
      JS.Append("{\n");
      JS.Append("IsPaused = false;\n");
      JS.Append("}\n");

      JS.Append("function Stop()\n");
      JS.Append("{\n");
      JS.Append("IsPaused = true;\n");
      JS.Append("}\n");

      JS.Append("function MoveLeft()\n");
      JS.Append("{\n");
      JS.Append("if( IsPaused || pix == -(divWidth - divVirtualWidth)) return;\n");
      JS.AppendFormat("var objtbl = document.getElementById('{0}');\n", tblBase.ClientID);
      JS.Append("pix = parseInt(objtbl.style.left.replace(\"px\",\"\"));\n");
      JS.Append("pix = pix - 1;\n");
      JS.Append("objtbl.style.left=pix.toString() + \"px\";\n");
      JS.Append("setTimeout(\"MoveLeft()\",\"10\");\n");
      JS.Append("}\n");

      JS.Append("function StopMoveLeft()\n");
      JS.Append("{\n");
      JS.AppendFormat("if( !IsPaused || pix % {0} == 0) return;\n", _ImageWidth + 1);
      JS.AppendFormat("var objtbl = document.getElementById('{0}');\n", tblBase.ClientID);
      JS.Append("pix = parseInt(objtbl.style.left.replace(\"px\",\"\"));\n");
      JS.Append("pix = pix - 1;\n");
      JS.Append("objtbl.style.left=pix.toString() + \"px\";\n");
      JS.Append("setTimeout(\"StopMoveLeft()\",\"10\");\n");
      JS.Append("}\n");

      JS.Append("function MoveRight()\n");
      JS.Append("{\n");
      JS.Append("if( IsPaused || pix == 0) return;\n");
      JS.AppendFormat("var objtbl = document.getElementById('{0}');\n", tblBase.ClientID);
      JS.Append("pix = parseInt(objtbl.style.left.replace(\"px\",\"\"));\n");
      JS.Append("pix = pix + 1;\n");
      JS.Append("objtbl.style.left=pix.toString() + \"px\";\n");