表格怎么随机变换背景图片?

来源:百度知道 编辑:UC知道 时间:2024/07/07 16:15:32
在table里背景图片怎么随机变换?
或者延时变换?

<table width=500 height=200 id=tbl>
<tr>
<td></td>
</tr>
</table>
<script>
var imgtol;
var imgid;
imgtol=10;//背景图总数
function showbg(){
imgid = Math.floor(Math.random() * imgtol+1);
document.getElementById("tbl").style.background="url(http://bbs.dvbbs.net/Images/userface/image"+imgid+".gif)";
}
//下面两行必须注释掉一行
showbg(); //正常显示
//setTimeout("showbg()",500); //延时显示
</script>