javascript 間隔時間滾動的圖文小欄目

來源:互聯網
上載者:User
提示:您可以先修改部分代碼再運行

<p><meta content="text/html;charset=gb2312" http-equiv="content-type" /></p><!--把下面代碼加到<head>與</head>之間--><p><style type="text/css">*{margin:0;padding:0;border:0;list-style:none;} body{font:12px Verdana,Geneva,sans-serif;line-height:18px;color:#333;} a{text-decoration:none;color:#004285;font-size:14px;font-weight:bold;} a:hover{text-decoration:underline;color:#C33;} .rig{border:1px solid #dedede;width:282px;margin-bottom:5px;position:relative;background:#fff;} #qy a{font-size:12px;} h5 span a{font-size:12px;font-weight:normal;color:#333;} h5{padding:0 10px;font-size:14px;height:30px;line-height:30px;background:url(http://www.111cn.net/blog/upload/image/20100507201433.jpg) left center repeat-x;border-bottom:1px solid #dedede;} span{float:right;} #btm{position:absolute;right:0;top:60px;width:12px;height:43px;background:url(http://www.111cn.net/blog/upload/image/20100507201546.gif) no-repeat;overflow:hidden;} #btm a{display:block;height:22px;} #btm a#up:hover{background:url(http://www.111cn.net/blog/upload/image/20100507201546.gif) -13px top no-repeat;} #btm a#dw:hover{background:url(http://www.111cn.net/blog/upload/image/20100507201546.gif) -26px -22px no-repeat;}</style></p><p> </p><!--把下面代碼加到<body>與</body>之間--><div class="rig"><h5><span>更多>></span>精彩企業專題</h5><div id="qy" onmouseout="qiScrollAmount=2" onmouseover="qiScrollAmount=0"><ul> <li id="tab1"> <table cellspacing="0" cellpadding="0" width="256" border="0"> <tbody> <tr> <td height="70"></td> </tr> <tr> <td height="24"><span>進入專題</span> <p>徐工集團專題</p> </td> </tr> <tr> <td height="70"></td> </tr> <tr> <td height="24"><span>進入專題</span> <p>三一重工專題</p> </td> </tr> </tbody> </table> </li> <li id="tab2"> </li></ul></div><div id="btm"> </div></div><script language="javascript">var qoMarquee = document.getElementById("qy");//滾動對象var tab1 = document.getElementById("tab1");var tab2 = document.getElementById("tab2");var qiLineHeight = 94;//單行高度,像素IEvar qiLineCount = 0;//實際行數var qiScrollAmount = 2;//每次滾動高度,像素(速度)var speed1=2000;//每次停留時間var speed2=1;//捲動速度tab2.innerHTML=tab1.innerHTML;var alink=document.getElementById('btm').getElementsByTagName('a');for(var i=0;i<alink.length;i++){alink[i].onfocus=function(){this.blur();}}function run() {if(qoMarquee.scrollTop==2*qiLineHeight){qoMarquee.scrollTop=0;window.setTimeout( "run()", speed2 );}//重設並接著滾動else{qoMarquee.scrollTop +=qiScrollAmount;if ( qoMarquee.scrollTop % qiLineHeight == 0 ) {window.setTimeout( "run()", speed1 );}//如果滿格等待N秒else {window.setTimeout( "run()", speed2 );}//正常滾動}}function up(){qiScrollAmount = 0;var amount=1;if(qoMarquee.scrollTop==2*qiLineHeight) qoMarquee.scrollTop=0;qoMarquee.scrollTop +=amount;if ( qoMarquee.scrollTop % qiLineHeight == 0 ) {amount=0;window.setTimeout( "qiScrollAmount = 2", speed1 );}else window.setTimeout( up(), 1 );}function dw(){qiScrollAmount = 0;var amount=1;if(qoMarquee.scrollTop==0) qoMarquee.scrollTop=2*qiLineHeight;qoMarquee.scrollTop -=amount;if ( qoMarquee.scrollTop % qiLineHeight == 0 ) {amount=0;window.setTimeout( "qiScrollAmount = 2", speed1 );}else window.setTimeout( dw(), 1 );}window.setTimeout( "run()", speed1 );</script><p> </p><p> </p>
提示:您可以先修改部分代碼再運行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.