普通的跑马灯效果我会
<script language="javascript">
<!--
marqueesHeight=100;
stopscroll=false;
with(marquees){
noWrap=true;
style.width=0;
style.height=marqueesHeight;
style.overflowY="hidden";
onmouseover=new Function("stopscroll=true");
onmouseout=new Function("stopscroll=false");
}document.write('<div id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>');
function init(){ while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;setInterval("scrollUp()",50);
}
document.body.onload=init;
preTop=0;
function scrollUp(){
if(stopscroll==true) return;
preTop=marquees.scrollTop;
marquees.scrollTop+=1; if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight+1;
}
}
-->
</script>
然后我在页面上放一个div 显示跑马灯的内容
<div id="marquees"><a href="#">链接1</a><br>
<a href="#">链接2</a><br>
<a href="#">链接3</a><br>
<a href="#">链接4</a><br>
</div>但是这些内容都是固定写死的,我现在要显示的是数据库的读出来的一条条纪录,而且要实现自动换行,
一条记录一行,应该怎么写,最好能给出具体方法和代码.
<script language="javascript">
<!--
marqueesHeight=100;
stopscroll=false;
with(marquees){
noWrap=true;
style.width=0;
style.height=marqueesHeight;
style.overflowY="hidden";
onmouseover=new Function("stopscroll=true");
onmouseout=new Function("stopscroll=false");
}document.write('<div id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>');
function init(){ while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;setInterval("scrollUp()",50);
}
document.body.onload=init;
preTop=0;
function scrollUp(){
if(stopscroll==true) return;
preTop=marquees.scrollTop;
marquees.scrollTop+=1; if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight+1;
}
}
-->
</script>
然后我在页面上放一个div 显示跑马灯的内容
<div id="marquees"><a href="#">链接1</a><br>
<a href="#">链接2</a><br>
<a href="#">链接3</a><br>
<a href="#">链接4</a><br>
</div>但是这些内容都是固定写死的,我现在要显示的是数据库的读出来的一条条纪录,而且要实现自动换行,
一条记录一行,应该怎么写,最好能给出具体方法和代码.
<div id="marquees">
<% while not rs.eof %> <!-- 关键就是这里用个循环输出一下就行了 -->
<a href="#"><%=rs("link")%></a> <br>
<% rs.movenext %>
<% loop %>
</div>