日期:2014-05-16  浏览次数:20485 次

可否实现定时换行的效果,谢谢
每次只显示一行,上下滚动,不要走马灯那样的,我见有网站实现过,可我想了很久都不知道怎么做,谢谢大家帮忙

<table width="777" border="0" cellspacing="0" cellpadding="0">
  <tr>
  <td>aaaaaaaa</td>
  </tr>
  <tr>
  <td>bbbbbbbb</td>
  </tr>
  <tr>
  <td>ccccccc</td>
  </tr>
  <tr>
  <td>dddddddd</td>
  </tr>
</table>

------解决方案--------------------
大致参照一下吧:

(只能在ie下跑,没有花更多时间去写一个兼容firefox的,不好意思阿)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
 <head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
 </head>

 <body>
<table id="tbl1" border="1" width="300">
<tr>
<td>
start
</td>
</tr>
<tr>
<td>
go
</td>
</tr>
</table>
 </body>
</html>

<script language="JavaScript">
<!--
function getObj(id) {
return document.getElementById(id);
}

var _s = [
"aaaaaaaaaaaaaaaaaaa",
"bbbbbbbbbbbbbbbbbbbb",
"cccccccccccccc",
"dddddddddddddddddddd",
"eeeeeeeeeeeeeeeeeeeeee",
"ffffffffffffff",
"ggggggggggggggggggggg"
];

(function() {
var nowRow = 0;

var tbl = getObj("tbl1");

setInterval(function() {
var len = tbl.rows.length;

tbl.rows[0].removeNode(true);

var newRow = tbl.insertRow(1);
var newCell = newRow.insertCell();

if (nowRow > 6)
{
nowRow = 0;
}
newCell.insertAdjacentHTML("AfterBegin", _s[nowRow++]);
}, 1000);
})();
//-->
</script>