<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>张力仪</title> <style type="text/css"> td {font-size: 12px;} </style> </head> <body> <table width="400" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="15" valign="top"><img src="http://www.codefans.net/jscss/demoimg/201010/news.gif" alt="" width="11" height="11" /></td> <td width="64">最新消息:</td> <td width="321"><script> var marqueeContent=new Array(); //滚动主题 marqueeContent[0]=‘<a href="#" target="_blank">学习编程,欢迎访问源码爱好者!</a>‘; marqueeContent[1]=‘<a href="#" target="_blank">精品源代码下载。</a>‘; marqueeContent[2]=‘<a href="#" target="_blank">专注于提供编程源码及素材下载及实例教程。</a>‘; marqueeContent[3]=‘<a href="#" target="_blank">旅行是需要一种心情,更重要的是,需要一种冲动。</a>‘; marqueeContent[4]=‘<a href="#" target="_blank">随时用零碎的时间(如等人、排队等)做零碎的事情。</a>‘; var marqueeInterval=new Array(); //定义一些常用而且要经常用到的变量 var marqueeId=0; var marqueeDelay=4000; var marqueeHeight=15; function initMarquee() { var str=marqueeContent[0]; document.write(‘<div id=marqueeBox style="overflow:hidden;height:‘+marqueeHeight+‘px" onmouseover="clearInterval(marqueeInterval[0])" onmouseout="marqueeInterval[0]=setInterval(\‘startMarquee()\‘,marqueeDelay)"><div>‘+str+‘</div></div>‘); marqueeId++; marqueeInterval[0]=setInterval("startMarquee()",marqueeDelay); } function startMarquee() { var str=marqueeContent[marqueeId]; marqueeId++; if(marqueeId>=marqueeContent.length) marqueeId=0; if(marqueeBox.childNodes.length==1) { var nextLine=document.createElement(‘DIV‘); nextLine.innerHTML=str; marqueeBox.appendChild(nextLine); } else { marqueeBox.childNodes[0].innerHTML=str; marqueeBox.appendChild(marqueeBox.childNodes[0]); marqueeBox.scrollTop=0; } clearInterval(marqueeInterval[1]); marqueeInterval[1]=setInterval("scrollMarquee()",10); } function scrollMarquee() { marqueeBox.scrollTop++; if(marqueeBox.scrollTop%marqueeHeight==marqueeHeight){ clearInterval(marqueeInterval[1]); } } initMarquee(); </script></td> </tr> </table> </body> </html>
单行消息滚动代码,可添加无数个,布布扣,bubuko.com
原文:http://www.cnblogs.com/youtianxia/p/3889528.html