用javascript代替marquee的滚动字幕效果代码
2008-04-08 12:19
741 查看
1 简单滚动
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<html xmlns="http://www.w3.org/1999/xhtml">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<title>热点新闻</title>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<style type="text/css">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
<!--
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
body {...}{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
margin: 0px;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
font-size: 12px;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
color: #938C43;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
line-height: 150%;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
text-align:center;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
a:link{...}{color: #9D943A;font-size:12px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
a:hover{...}{color: #FF3300;font-size:12px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
a:visited{...}{color: #9D943A;font-size:12px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
a.red:link{...}{color: #ff0000;font-size:12px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
a.red:hover{...}{color: #ff0000;font-size:12px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
a.red:visited{...}{color: #ff0000;font-size:12px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
#marqueeBox{...}{background:#f7f7f7;border:1px solid silver;padding:1px;text-align:center;margin:0 auto;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
-->
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</style>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<h4>滚动新闻</h4>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script language="JavaScript" type="text/javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var marqueeContent=new Array();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeContent[0]="<a href=http://xyq.163.com/news/2006/11/2-2-20061102170913.html target=_blank>用“梦幻密保”快速取回帐号密码</a>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeContent[1]="<a href=http://ekey.163.com/ target=_blank>网易将军令官方网站</a>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeContent[2]="<a href=http://xyq.163.com/download/wallpaper.htm target=_blank>最新壁纸下载</a>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeContent[3]="<a href=http://xyq.163.com/download/around.htm target=_blank>最新屏保下载</a>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var marqueeInterval=new Array();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var marqueeId=0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var marqueeDelay=2000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var marqueeHeight=20;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function initMarquee() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var str=marqueeContent[0];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.write('<div id="marqueeBox" style="overflow:hidden;width:250px;height:'+marqueeHeight+'px" onmouseover="clearInterval(marqueeInterval[0])" onmouseout="marqueeInterval[0]=setInterval('startMarquee()',marqueeDelay)"><div>'+str+'</div></div>');
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeId++;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeInterval[0]=setInterval("startMarquee()",marqueeDelay);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function startMarquee() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var str=marqueeContent[marqueeId];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeId++;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(marqueeId>=marqueeContent.length) marqueeId=0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if(document.getElementById("marqueeBox").childNodes.length==1) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var nextLine=document.createElement('DIV');
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
nextLine.innerHTML=str;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.getElementById("marqueeBox").appendChild(nextLine);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
else ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.getElementById("marqueeBox").childNodes[0].innerHTML=str;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.getElementById("marqueeBox").appendChild(document.getElementById("marqueeBox").childNodes[0]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.getElementById("marqueeBox").scrollTop=0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
clearInterval(marqueeInterval[1]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeInterval[1]=setInterval("scrollMarquee()",20);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function scrollMarquee() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.getElementById("marqueeBox").scrollTop++;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if(document.getElementById("marqueeBox").scrollTop%marqueeHeight==(marqueeHeight-1))...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
clearInterval(marqueeInterval[1]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
initMarquee();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</html>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
个人观点:从web可用性角度上讲,我们在采用这段代码的同时要考虑到noscript环境下的可用性,建议将内容还是以下边代码的形式出现在页面中。如:
<div id="newslist">
<ul>
<li><a href=http://xyq.163.com/news/2006/11/2-2-20061102170913.html target=_blank>用“梦幻密保”快速取回帐号密码</a></li>
<li><a href=http://ekey.163.com/ target=_blank>网易将军令官方网站</a></li>
<li><a href=http://xyq.163.com/download/wallpaper.htm target=_blank>最新壁纸下载</a></li>
<li><a href=http://xyq.163.com/download/around.htm target=_blank>最新屏保下载</a></li>
</ul>
</div>
然后用脚本去设置隐藏,将列表项读进javascript中定义的数组中。即可达到在noscript环境下也能正常看到内容列表。
第二种方法:这个更强,能自动根据内容自动进行左右滚动,解决了宽度太小造成的截取问题。
原文作者:风动人
个人观点:从xhtml的语义化的角度看,页面内容中滥用div标签现象比较严重,可改成ul/li形式。
第三种是最精简的,代码非常少。
原文作者:cityvoice
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<html>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<title> SCROLL </title>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<style type="text/css">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
#infozone{...}{font-size:12px;color:#aa6;overflow:hidden;width:100px;height:20px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
#infozone div{...}{height:20px;line-height:20px;white-space:nowrap;overflow:hidden;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</style>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script type="text/javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var tc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
window.onload=function()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var o=document.getElementById('infozone');hscroll(o);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
window.setInterval(function()...{window.clearTimeout(tc);o.firstChild.style.marginLeft='0px';scrollup(o,20,0);},10000);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function scrollup(o,d,c)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if(d==c)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var t=o.firstChild.cloneNode(true);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
o.removeChild(o.firstChild);o.appendChild(t);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
t.style.marginTop=o.firstChild.style.marginTop='0px';
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
hscroll(o);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
else...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ch=false;var s=3,c=c+s,l=(c>=d?c-d:0);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
o.firstChild.style.marginTop=-c+l+'px';
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
window.setTimeout(function()...{scrollup(o,d,c-l)},50);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function hscroll(o)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var w1=o.firstChild.offsetWidth,w2=o.offsetWidth;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(w1<=w2)return;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
tc=window.setTimeout(function()...{hs(o,w1-w2,0,w1-w2)},3500);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function hs(o,d,c,p)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
c++;var t=(c>0?-c:c);o.firstChild.style.marginLeft=t+'px';
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if(c==d)...{if(d==0)...{tc=window.setTimeout(function()...{hs(o,p,0,p)},2500);}else tc=window.setTimeout(function()...{hs(o,0,-p,p)},3500);}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
else tc=window.setTimeout(function()...{hs(o,d,c,p)},5);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<div id="infozone"><div>温岚 - 屋顶(周杰伦 对唱版)</div><div>范玮琪 - 那些花儿</div><div>张韶涵 - 娃娃</div><div>孙楠&韩红 - 美丽的神话</div></div>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</html>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<HTML>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<HEAD>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<TITLE> New Document </TITLE>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<META NAME="Generator" CONTENT="EditPlus">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<META NAME="Author" CONTENT="">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<META NAME="Keywords" CONTENT="">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<META NAME="Description" CONTENT="">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<style type="text/css">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
#newslist{...}{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
background:#f7f7f7;border:1px solid silver;padding:1px;height:20px;line-height:20px;width:300px;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
#contain{...}{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
font-size:12px;overflow:hidden;list-style:none;width:300px;height:20px;margin:0px;padding:0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
#contain li{...}{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
height:20px;line-height:20px;white-space:nowrap;overflow:hidden;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</style>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</HEAD>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<BODY>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<div id="newslist">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<ul id="contain">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li><a href="http:/www.iwcn.net">温岚 - 屋顶(左右摆动)</a></li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li><a href="http:/www.iwcn.net">范玮琪 - 那些花儿</a></li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li><a href="http:/www.iwcn.net">张韶涵 - 娃娃</a></li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li><a href="http:/www.iwcn.net">孙楠&韩红 - 美丽的神话</a></li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li><a href="http:/www.iwcn.net">张信哲 - 白月光</a></li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</ul>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</div>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<SCRIPT LANGUAGE="JavaScript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function xx()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var container=document.getElementById("contain");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
container.appendChild(container.firstChild);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
setInterval("xx()",3000);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</SCRIPT>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</BODY>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</HTML>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
本文来自: 脚本之家(www.jb51.net) 详细出处参考:/article/1261636.html
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<html xmlns="http://www.w3.org/1999/xhtml">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<title>热点新闻</title>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<style type="text/css">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
<!--
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
body {...}{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
margin: 0px;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
font-size: 12px;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
color: #938C43;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
line-height: 150%;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
text-align:center;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
a:link{...}{color: #9D943A;font-size:12px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
a:hover{...}{color: #FF3300;font-size:12px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
a:visited{...}{color: #9D943A;font-size:12px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
a.red:link{...}{color: #ff0000;font-size:12px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
a.red:hover{...}{color: #ff0000;font-size:12px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
a.red:visited{...}{color: #ff0000;font-size:12px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
#marqueeBox{...}{background:#f7f7f7;border:1px solid silver;padding:1px;text-align:center;margin:0 auto;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
-->
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</style>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<h4>滚动新闻</h4>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script language="JavaScript" type="text/javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var marqueeContent=new Array();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeContent[0]="<a href=http://xyq.163.com/news/2006/11/2-2-20061102170913.html target=_blank>用“梦幻密保”快速取回帐号密码</a>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeContent[1]="<a href=http://ekey.163.com/ target=_blank>网易将军令官方网站</a>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeContent[2]="<a href=http://xyq.163.com/download/wallpaper.htm target=_blank>最新壁纸下载</a>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeContent[3]="<a href=http://xyq.163.com/download/around.htm target=_blank>最新屏保下载</a>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var marqueeInterval=new Array();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var marqueeId=0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var marqueeDelay=2000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var marqueeHeight=20;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function initMarquee() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var str=marqueeContent[0];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.write('<div id="marqueeBox" style="overflow:hidden;width:250px;height:'+marqueeHeight+'px" onmouseover="clearInterval(marqueeInterval[0])" onmouseout="marqueeInterval[0]=setInterval('startMarquee()',marqueeDelay)"><div>'+str+'</div></div>');
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeId++;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeInterval[0]=setInterval("startMarquee()",marqueeDelay);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function startMarquee() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var str=marqueeContent[marqueeId];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeId++;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(marqueeId>=marqueeContent.length) marqueeId=0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if(document.getElementById("marqueeBox").childNodes.length==1) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var nextLine=document.createElement('DIV');
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
nextLine.innerHTML=str;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.getElementById("marqueeBox").appendChild(nextLine);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
else ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.getElementById("marqueeBox").childNodes[0].innerHTML=str;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.getElementById("marqueeBox").appendChild(document.getElementById("marqueeBox").childNodes[0]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.getElementById("marqueeBox").scrollTop=0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
clearInterval(marqueeInterval[1]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
marqueeInterval[1]=setInterval("scrollMarquee()",20);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function scrollMarquee() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.getElementById("marqueeBox").scrollTop++;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if(document.getElementById("marqueeBox").scrollTop%marqueeHeight==(marqueeHeight-1))...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
clearInterval(marqueeInterval[1]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
initMarquee();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</html>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
个人观点:从web可用性角度上讲,我们在采用这段代码的同时要考虑到noscript环境下的可用性,建议将内容还是以下边代码的形式出现在页面中。如:
<div id="newslist">
<ul>
<li><a href=http://xyq.163.com/news/2006/11/2-2-20061102170913.html target=_blank>用“梦幻密保”快速取回帐号密码</a></li>
<li><a href=http://ekey.163.com/ target=_blank>网易将军令官方网站</a></li>
<li><a href=http://xyq.163.com/download/wallpaper.htm target=_blank>最新壁纸下载</a></li>
<li><a href=http://xyq.163.com/download/around.htm target=_blank>最新屏保下载</a></li>
</ul>
</div>
然后用脚本去设置隐藏,将列表项读进javascript中定义的数组中。即可达到在noscript环境下也能正常看到内容列表。
第二种方法:这个更强,能自动根据内容自动进行左右滚动,解决了宽度太小造成的截取问题。
原文作者:风动人
个人观点:从xhtml的语义化的角度看,页面内容中滥用div标签现象比较严重,可改成ul/li形式。
第三种是最精简的,代码非常少。
原文作者:cityvoice
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<html>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<title> SCROLL </title>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<style type="text/css">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
#infozone{...}{font-size:12px;color:#aa6;overflow:hidden;width:100px;height:20px;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
#infozone div{...}{height:20px;line-height:20px;white-space:nowrap;overflow:hidden;}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</style>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script type="text/javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var tc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
window.onload=function()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var o=document.getElementById('infozone');hscroll(o);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
window.setInterval(function()...{window.clearTimeout(tc);o.firstChild.style.marginLeft='0px';scrollup(o,20,0);},10000);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function scrollup(o,d,c)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if(d==c)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var t=o.firstChild.cloneNode(true);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
o.removeChild(o.firstChild);o.appendChild(t);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
t.style.marginTop=o.firstChild.style.marginTop='0px';
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
hscroll(o);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
else...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ch=false;var s=3,c=c+s,l=(c>=d?c-d:0);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
o.firstChild.style.marginTop=-c+l+'px';
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
window.setTimeout(function()...{scrollup(o,d,c-l)},50);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function hscroll(o)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var w1=o.firstChild.offsetWidth,w2=o.offsetWidth;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(w1<=w2)return;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
tc=window.setTimeout(function()...{hs(o,w1-w2,0,w1-w2)},3500);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function hs(o,d,c,p)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
c++;var t=(c>0?-c:c);o.firstChild.style.marginLeft=t+'px';
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if(c==d)...{if(d==0)...{tc=window.setTimeout(function()...{hs(o,p,0,p)},2500);}else tc=window.setTimeout(function()...{hs(o,0,-p,p)},3500);}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
else tc=window.setTimeout(function()...{hs(o,d,c,p)},5);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<div id="infozone"><div>温岚 - 屋顶(周杰伦 对唱版)</div><div>范玮琪 - 那些花儿</div><div>张韶涵 - 娃娃</div><div>孙楠&韩红 - 美丽的神话</div></div>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</html>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<HTML>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<HEAD>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<TITLE> New Document </TITLE>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<META NAME="Generator" CONTENT="EditPlus">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<META NAME="Author" CONTENT="">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<META NAME="Keywords" CONTENT="">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<META NAME="Description" CONTENT="">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<style type="text/css">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
#newslist{...}{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
background:#f7f7f7;border:1px solid silver;padding:1px;height:20px;line-height:20px;width:300px;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
#contain{...}{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
font-size:12px;overflow:hidden;list-style:none;width:300px;height:20px;margin:0px;padding:0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
#contain li{...}{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
height:20px;line-height:20px;white-space:nowrap;overflow:hidden;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</style>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</HEAD>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<BODY>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<div id="newslist">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<ul id="contain">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li><a href="http:/www.iwcn.net">温岚 - 屋顶(左右摆动)</a></li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li><a href="http:/www.iwcn.net">范玮琪 - 那些花儿</a></li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li><a href="http:/www.iwcn.net">张韶涵 - 娃娃</a></li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li><a href="http:/www.iwcn.net">孙楠&韩红 - 美丽的神话</a></li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li><a href="http:/www.iwcn.net">张信哲 - 白月光</a></li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</ul>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</div>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<SCRIPT LANGUAGE="JavaScript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function xx()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var container=document.getElementById("contain");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
container.appendChild(container.firstChild);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
setInterval("xx()",3000);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</SCRIPT>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</BODY>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</HTML>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
本文来自: 脚本之家(www.jb51.net) 详细出处参考:/article/1261636.html
相关文章推荐
- 用javascript代替marquee的滚动字幕效果代码
- 用javascript实现代替marquee的滚动字幕效果代码
- 用javascript实现代替marquee的滚动字幕效果代码
- 用javascript代替marquee的滚动字幕效果代码
- 代替marquee的滚动字幕效果代码
- 代替marquee的滚动字幕效果代码
- 代替marquee的滚动字幕效果js代码
- javascript 模拟Marquee文字向左均匀滚动代码
- 用DIV 来代替JAVASCRIPT以实现无间隔新闻滚动的效果
- javascript跟随滚动效果插件代码(javascript Follow Plugin)
- [原创]分别用marquee和div+js实现首尾相连循环滚动效果,仅3行代码
- Marquee配合DIV实现的文字滚动效果代码
- 一个符合w3c标准的可以代替marquee标签实现翻滚效果的javascript 脚本
- 分别用marquee和div+js实现首尾相连循环滚动效果,仅3行代码
- JavaScript字幕滚动效果
- JavaScript代码实现图片循环滚动效果
- 2012.12.8一个符合w3c标准的可以代替marquee标签实现翻滚效果的javascript脚本
- javascript 实现滚动效果代码整理
- 使用JavaScript实现连续滚动字幕效果的方法
- JavaScript字幕滚动效果