问题描述
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/><title>自动轮播代码</title></head><styletype="text/css">.rollBox{width:704px;overflow:hidden;padding:12px05px6px;}.rollBox.LeftBotton{height:30px;width:19px;background:url(/images/btn_arrow_left.gif)no-repeat4px0;overflow:hidden;float:left;display:inline;margin:25px000;cursor:pointer;}.rollBox.RightBotton{height:52px;width:26px;background:url(/images/btn_arrow_right.gif)no-repeat4px0;overflow:hidden;float:left;display:inline;margin:25px000;cursor:pointer;}.rollBox.Cont{width:330px;overflow:hidden;float:left;}.rollBox.ScrCont{width:10000000px;}.rollBox.Cont.pic{width:80px;float:left;text-align:center;}.rollBox.Cont.picimg{padding:4px;background:#fff;border:1pxsolid#ccc;display:block;margin:0auto;}.rollBox.Cont.picp{line-height:26px;color:#505050;}.rollBox.Conta:link,.rollBox.Conta:visited{color:#626466;text-decoration:none;}.rollBox.Conta:hover{color:#f00;text-decoration:underline;}.rollBox#List1,.rollBox#List2{float:left;}</style><body><formid="form1"name="form1"method="post"action=""><%DimconnDB_ServerName="(local)SQLEXPRESS"'数据库名称(IP+实例名)DB_UserName="sa"'SQL用户名DB_PassWord="jacky.com"'SQL用户密码DB_DateBase="WEBSITE"'数据库名DB_Provider="SQLNCLI"'驱动程序sql="Provider="&DB_Provider&";UID="&DB_UserName&";Pwd="&DB_PassWord&";database="&DB_DateBase&";Server="&DB_ServerName&";"SetConn=Server.CreateObject("ADODB.Connection")Conn.Opensql%><divclass="rollBox"><divclass="LeftBotton"onMouseDown="ISL_GoUp()"onMouseUp="ISL_StopUp()"onMouseOut="ISL_StopUp()"></div><divclass="Cont"id="ISL_Cont"><divclass="ScrCont"><divid="List1"><!--图片列表begin--><%sql_luobo="select*from[website].[dbo].[pro]whereshowindex<>0orderbyberdesc"Setrs_luobo=conn.Execute(sql_luobo)whilenotrs_luobo.eof%><divclass="pic"><ahref="product/default.asp?prober=<%=rs_luobo("ber")%>"target="_blank"><imgsrc='<%=rs_luobo("photos22")%>'height="70"onload="returnimgzoom(this,600);style="cursor:pointer;"/></a></div><%rs_luobo.MoveNextwendrs_luobo.Closesetrs_luobo=nothing%></div><divid="List2"></div></div></div><divclass="RightBotton"onMouseDown="ISL_GoDown()"onMouseUp="ISL_StopDown()"onMouseOut="ISL_StopDown()"></div></div></div><scriptlanguage="javascript"type="text/javascript">varSpeed=0;//速度(毫秒)varSpace=1;//每次移动(px)varPageWidth=528;//翻页宽度varfill=0;//整体移位varMoveLock=false;varMoveTimeObj;varComp=0;varAutoPlayObj=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();functionGetObj(objName){if(document.getElementById){returneval('document.getElementById("'+objName+'")')}else{returneval('document.all.'+objName)}}functionAutoPlay(){//自动滚动clearInterval(AutoPlayObj);AutoPlayObj=setInterval('ISL_GoDown();ISL_StopDown();',3000);//间隔时间}functionISL_GoUp(){//上翻开始if(MoveLock)return;clearInterval(AutoPlayObj);MoveLock=true;MoveTimeObj=setInterval('ISL_ScrUp();',Speed);}functionISL_StopUp(){//上翻停止clearInterval(MoveTimeObj);if(GetObj('ISL_Cont').scrollLeft%PageWidth-fill!=0){Comp=fill-(GetObj('ISL_Cont').scrollLeft%PageWidth);CompScr();}else{MoveLock=false;}AutoPlay();}functionISL_ScrUp(){//上翻动作if(GetObj('ISL_Cont').scrollLeft<=0){GetObj('ISL_Cont').scrollLeft=GetObj('ISL_Cont').scrollLeft+GetObj('List1').offsetWidth}GetObj('ISL_Cont').scrollLeft-=Space;}functionISL_GoDown(){//下翻clearInterval(MoveTimeObj);if(MoveLock)return;clearInterval(AutoPlayObj);MoveLock=true;ISL_ScrDown();MoveTimeObj=setInterval('ISL_ScrDown()',Speed);}functionISL_StopDown(){//下翻停止clearInterval(MoveTimeObj);if(GetObj('ISL_Cont').scrollLeft%PageWidth-fill!=0){Comp=PageWidth-GetObj('ISL_Cont').scrollLeft%PageWidth+fill;CompScr();}else{MoveLock=false;}AutoPlay();}functionISL_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;}functionCompScr(){varnum;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></form></body></html>
解决方案
解决方案二:
等待高手。
解决方案三:
最佳答案<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/><title>自动轮播代码</title><styletype="text/css"><!--.rollBox{width:704px;overflow:hidden;padding:12px05px6px;}.rollBox.LeftBotton{height:52px;width:19px;background:url(/images/btn_arrow_left.gif)no-repeat4px0;overflow:hidden;float:left;display:inline;margin:25px000;cursor:pointer;}.rollBox.RightBotton{height:52px;width:20px;background:url(/images/btn_arrow_right.gif)no-repeat4px0;overflow:hidden;float:left;display:inline;margin:25px000;cursor:pointer;}.rollBox.Cont{width:330px;overflow:hidden;float:left;}.rollBox.ScrCont{width:10000000px;}.rollBox.Cont.pic{width:80px;float:left;text-align:center;}.rollBox.Cont.picimg{padding:4px;background:#fff;border:1pxsolid#ccc;display:block;margin:0auto;}.rollBox.Cont.picp{line-height:26px;color:#505050;}.rollBox.Conta:link,.rollBox.Conta:visited{color:#626466;text-decoration:none;}.rollBox.Conta:hover{color:#f00;text-decoration:underline;}.rollBox#List1,.rollBox#List2{float:left;}.style2{font-size:10px;font-family:"新宋体";font-weight:bold;color:#0000FF;}--></style><!--rollBox.LeftBotton{height:52px;width:19px;background:url(/images/btn_arrow_left.gif)no-repeat4px0;overflow:hidden;float:left;这一段是显示左边按钮.rollBox.RightBotton{height:52px;width:20px;background:url(/images/btn_arrow_right.gif)no-repeat4px0;overflow:hidden;float:这一段是显示右边按钮--></head><body><divclass="rollBox"><divclass="LeftBotton"onMouseDown="ISL_GoUp()"onMouseUp="ISL_StopUp()"onMouseOut="ISL_StopUp()"></div><divclass="Cont"id="ISL_Cont"><divclass="ScrCont"><divid="List1"><!--图片列表begin--><%DimconnDB_ServerName="(local)SQLEXPRESS"'数据库名称(IP+实例名)DB_UserName="sa"'SQL用户名DB_PassWord="jacky.com"'SQL用户密码DB_DateBase="WEBSITE"'数据库名DB_Provider="SQLNCLI"'驱动程序sql="Provider="&DB_Provider&";UID="&DB_UserName&";Pwd="&DB_PassWord&";database="&DB_DateBase&";Server="&DB_ServerName&";"SetConn=Server.CreateObject("ADODB.Connection")Conn.Opensqlsql_luobo="select*from[website].[dbo].[pro]whereshowindex<>0orderbyberdesc"Setrs_luobo=conn.Execute(sql_luobo)whilenotrs_luobo.eof%><divclass="pic"><ahref="product/default.asp?prober=<%=rs_luobo("ber")%>"target="_blank"><imgsrc="<%=rs_luobo("photos22")%>"height="70"onloadstyle="cursor:pointer;"/></a><spanclass="style2"><%=rs_luobo("name")%></span></div><%rs_luobo.MoveNextwendrs_luobo.Closesetrs_luobo=nothing%></div><divid="List2"></div></div></div><divclass="RightBotton"onMouseDown="ISL_GoDown()"onMouseUp="ISL_StopDown()"onMouseOut="ISL_StopDown()"></div></div></div><scriptlanguage="javascript"type="text/javascript"><!--//--><![CDATA[//><!--//图片滚动列表varSpeed=1;//速度(毫秒)speed的值越大速度越慢varSpace=1;//每次移动(px)varPageWidth=132;//翻页宽度varfill=0;//整体移位varMoveLock=false;//moveLock是一个锁当它为false滚动继续,如果为true时则关闭图片滚动动作varMoveTimeObj;varComp=0;varAutoPlayObj=null;GetObj("List2").innerHTML=GetObj("List1").innerHTML;//克隆list2为list1GetObj('ISL_Cont').scrollLeft=fill;//滚动框里面的内容GetObj("ISL_Cont").onmouseover=function(){clearInterval(AutoPlayObj);}//当鼠标经过时,清除定时器达到图片停止滚动的功能GetObj("ISL_Cont").onmouseout=function(){AutoPlay();}//当鼠标离开时,图片继续滚动AutoPlay();functionGetObj(objName){if(document.getElementById){returneval('document.getElementById("'+objName+'")')}else{returneval('document.all.'+objName)}}functionAutoPlay(){//自动滚动clearInterval(AutoPlayObj);AutoPlayObj=setInterval('ISL_GoDown();ISL_StopDown();',30);//自动滚动间隔时间}functionISL_GoUp(){//上翻开始if(MoveLock)return;clearInterval(AutoPlayObj);MoveLock=true;MoveTimeObj=setInterval('ISL_ScrUp();',Speed);}functionISL_StopUp(){//上翻停止clearInterval(MoveTimeObj);if(GetObj('ISL_Cont').scrollLeft%PageWidth-fill!=0){Comp=fill-(GetObj('ISL_Cont').scrollLeft%PageWidth);CompScr();}else{MoveLock=false;}AutoPlay();}functionISL_ScrUp(){//上翻动作if(GetObj('ISL_Cont').scrollLeft<=0){GetObj('ISL_Cont').scrollLeft=GetObj('ISL_Cont').scrollLeft+GetObj('List1').offsetWidth}GetObj('ISL_Cont').scrollLeft-=Space;}functionISL_GoDown(){//下翻clearInterval(MoveTimeObj);if(MoveLock)return;clearInterval(AutoPlayObj);MoveLock=true;ISL_ScrDown();MoveTimeObj=setInterval('ISL_ScrDown()',Speed);}functionISL_StopDown(){//下翻停止clearInterval(MoveTimeObj);if(GetObj('ISL_Cont').scrollLeft%PageWidth-fill!=0){Comp=PageWidth-GetObj('ISL_Cont').scrollLeft%PageWidth+fill;CompScr();}else{MoveLock=false;}AutoPlay();}functionISL_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;}functionCompScr(){varnum;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>//欢迎各位同仁来转载交流