六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 117|回复: 0

带上翻、下翻按钮让div层垂直滚动特效

[复制链接]

升级  62%

7

主题

7

主题

7

主题

童生

Rank: 1

积分
31
 楼主| 发表于 2013-2-7 21:06:45 | 显示全部楼层 |阅读模式
<html> <head>  <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  <title>图片上下滚动</title> </head> <BODY>  <div id=makewing style="height:60;">   <table width="778" border="0" cellpadding="0" cellspacing="0" align="center">    <tr>     <td height="60" bgcolor="#66CCFF" align="center">      内容1     </td>    </tr>    <tr>     <td height="60" bgcolor="#FFCC66" align="center">      内容2     </td>    </tr>    <tr>     <td height="60" bgcolor="#99CC66" align="center">      内容3     </td>    </tr>   </table>  </div>  <div id="bb" style="margin-left:450px;">   <input type="button" value="上翻"  />   <input type="button" value="下翻"  />  </div> </BODY> <script type="text/javascript">      marqueesHeight=60;      stopscroll=false;      with(bb){        onmouseover=new Function("stopscroll=true");        onmouseout=new Function("stopscroll=false");      }      with(makewing){        style.height=marqueesHeight;        style.overflowX="visible";        style.overflowY="hidden";        noWrap=true;        onmouseover=new Function("stopscroll=true");        onmouseout=new Function("stopscroll=false");      }      preTop=0; currentTop=10; stoptime=0;      makewing.innerHTML+=makewing.innerHTML;      scoll=0;scollup=0;scolldown=0;t=10;      function init_srolltext(id){        if(id==0){           makewing.scrollTop=0;           scoll=setInterval("scrollUp(0)",1);        }else if(id==1){           if(scollup==0){              stopscroll=false;              scollup=setInterval("scrollUp(1)",1);           }        }else{           if(scolldown==0){              stopscroll=false;              scolldown=setInterval("scrollUp(-1)",1);           }        }       }function scrollUp(id){if(id==0){if(stopscroll==true) return;currentTop+=1;if(currentTop==11){   stoptime+=1;   currentTop-=1;   if(stoptime==300)  {    currentTop=0;    stoptime=0;   }}else { if(300==makewing.scrollTop){    makewing.scrollTop=120;    makewing.scrollTop+=6;   }else{      makewing.scrollTop+=6;   }}}else if(id==1){  window.clearInterval(scoll);   t--;  if(t==0){   window.clearInterval(scollup);    stopscroll=true;    scoll=setInterval("scrollUp(0)",1);    t=10; scollup=0;  }   if(300==makewing.scrollTop){    makewing.scrollTop=120;    makewing.scrollTop+=6;   }else{      makewing.scrollTop+=6;   }  }else{     window.clearInterval(scoll);     t--;  if(t==0){   window.clearInterval(scolldown);    stopscroll=true;    scoll=setInterval("scrollUp(0)",1);    t=10; scolldown=0;  }   if(0==makewing.scrollTop){    makewing.scrollTop=180;    makewing.scrollTop-=6;   }else{      makewing.scrollTop-=6;   }    }}init_srolltext(0);</script></HTML> 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表