首页上一页 1 下一页尾页 1 条记录 1/1页
我写的关于javascript中图片的随机显示问题为什么不行?错在哪里?怎样改?
发表在C#图书答疑
2013-06-18
是否精华
是
否
版块置顶:
是
否
<html>
<title>
</title>
<head>
</head>
<body>
<script language="javascript">
function randompic()
{
var i=Math.floor(Math.random()*5);
var src="";
switch(i)
{
case 0:
src="16.gif";
break;
case 1:
src="17.gif";
break;
case 2:
src="19.gif";
break;
case 3:
src="20.gif";
break;
case 4:
src="16.gif";
break;
}
var a=document.getElementById("ds");
a.background=src;
setTimeout("randompic()",1000);
}
</script>
<div style="width:82px;height:83px;margin:0 auto;">
<img id="ds" onload="randompic()">
</div>
</body>
</html>
<title>
</title>
<head>
</head>
<body>
<script language="javascript">
function randompic()
{
var i=Math.floor(Math.random()*5);
var src="";
switch(i)
{
case 0:
src="16.gif";
break;
case 1:
src="17.gif";
break;
case 2:
src="19.gif";
break;
case 3:
src="20.gif";
break;
case 4:
src="16.gif";
break;
}
var a=document.getElementById("ds");
a.background=src;
setTimeout("randompic()",1000);
}
</script>
<div style="width:82px;height:83px;margin:0 auto;">
<img id="ds" onload="randompic()">
</div>
</body>
</html>