现在网上很多轮显广告图片的例子,以下是轮显从数据库提取出来的新闻标题的范例,把div里面的表格换成动态的就可以了,为了让代码和思路清晰,再此没有套动态TABLE列表:
<table cellSpacing=0 cellPadding=0 width=527 align=center
border=0>
<tr>
<td vAlign=middle background=images/index_22.gif
height=115>
<div id="divone">
<table cellSpacing=1 cellPadding=1 width=500
align=center border=1>
<tr>
<td> 这是轮显的第一排字
<div align=center></div></td>
</tr>
</table> </div>
<div id="divtwo" >
<table cellSpacing=1 cellPadding=1 width=500
align=center border=1>
<tr>
<td> 这是轮显的第二排字
<div align=center></div></td>
</tr>
</table>
</div>
<div id="divthree" >
<table cellSpacing=1 cellPadding=1 width=500
align=center border=1>
<tr>
<td> 这是轮显的第三排字
<div align=center></div></td>
</tr>
</table></div>
<div id="divtfour" >
<table cellSpacing=1 cellPadding=1 width=500
align=center border=1>
<tr>
<td> 这是轮显的第四排字
<div align=center></div></td>
</tr>
</table> </div>
<SCRIPT LANGUAGE="JavaScript">
//新闻轮显
function GE(a){return document.getElementById(a);}
function setwhile()
{
GE('divone').style.display='none';
GE('divtwo').style.display='';
GE('divthree').style.display='none';
GE('divtfour').style.display='none';
setTimeout("setone();", 2000);
}
function setone()
{
GE('divone').style.display='';
GE('divtwo').style.display='none';
GE('divthree').style.display='none';
GE('divtfour').style.display='none';
setTimeout("settwo();", 2000);
}
function settwo()
{
GE('divone').style.display='none';
GE('divtwo').style.display='none';
GE('divthree').style.display='';
GE('divtfour').style.display='none';
setTimeout("setthree();", 2000);
}
function setthree()
{
GE('divone').style.display='none';
GE('divtwo').style.display='none';
GE('divthree').style.display='none';
GE('divtfour').style.display='';
setTimeout("setwhile();", 2000);
}
setwhile();
</SCRIPT>
</td></tr>
</table>