日期:2014-05-18  浏览次数:20477 次

求滚动新闻显示方法
功能描述:N条新闻,要求不断滚动显示新闻标题?

ASP.Net请问用虾米控件显示,实现自动滚动最好阿?有例子吗?

------解决方案--------------------
Adratator
queen
------解决方案--------------------
<marquee> </marquee>
标签最方便
看看网站edu.jsmstc.com
------解决方案--------------------
先用DataGrid显示数据,外面嵌套层,设置层的属性,增加滚动条 <div style= "overflow:scroll "> </div>
------解决方案--------------------
<div id= "marquees ">
1.新闻标题 <br>
2.新闻标题 <br>
3.新闻标题 <br>
</div>

<script language= "JavaScript ">
marqueesHeight=120;
stopscroll=false;

with(marquees){
style.width=0;
style.height=marqueesHeight;
style.overflowX= "visible ";
style.overflowY= "hidden ";
noWrap=true;
onmouseover=new Function( "stopscroll=true ");
onmouseout=new Function( "stopscroll=false ");
}
document.write( ' <div id= "templayer " style= "position:absolute;z-index:1;visibility:hidden "> </div> ');

preTop=0; currentTop=0;

function init(){
templayer.innerHTML= " ";
while(templayer.offsetHeight <marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
setInterval( "scrollUp() ",150);
}
document.body.onload=init;

function scrollUp(){
if(stopscroll==true) return;
preTop=marquees.scrollTop;
marquees.scrollTop+=1;
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight;
marquees.scrollTop+=1;
}
}
</script>
------解决方案--------------------

<!-- 用户最新相册 -->
<!-- 首页最新照片开始 -->
<div id= "demo " style= 'text-align:top;overflow:hidden;height:514px;width:104px; '>
<table align= "top " cellpadding=0 cellspace= "0 " border= "0 ">
<tr>
<td id= "demo1 " valign= "top " style= "text-align:top; ">
ytreytreytreytreytreytreiutruytey <br>
ytreytreytreytreytreytreiutruytey <br>
ytreytreytreytreytreytreiutruytey <br>
ytreytreytreytreytreytreiutruytey <br>
ytreytreytreytreytreytreiutruytey <br>
ytreytreytreytreytreytreiutruytey <br>
ytreytreytreytreytreytreiutruytey <br>
ytreytreytreytreytreytreiutruytey <br>
ytreytreytreytreytreytreiutruytey <br>
ytreytreytreytreytreytreiutruytey <br>
ytreytreytreytreytreytreiutruytey <br>
ytreytreytreytreytreytreiutruytey <br>
</td>
</tr>
<tr>
<td id= "demo2 " valign= "top " style= "text-align:top; "> </td>
</tr>
</table>
</div>


<script>

var speed=30
demo2.innerHTML=demo1.innerHTML;
function Marquee(){
if(demo2.offsetHeight-demo.scrollTop <=0)
demo.scrollTop -= demo1.offsetHeight;
else{
demo.scrollTop++;
}
}
var MyMar=setInterval(Marquee,speed);
demo.onmouseover=function() {clearInterval(MyMar);}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed);}