haiou - 2008-11-4 19:51:00
下面是代码:
<script>
s=new Array(3)
s[0]=Math.floor(Math.random()*256)+""
s[1]=Math.floor(Math.random()*256)+""
s[2]=Math.floor(Math.random()*256)+""
a=s[0]+s[1]+s[2]
document.write("<body bgcolor="+a+">")
document.write("</body>")
</script>
<script>
s="icon/icon"+Math.floor(Math.random()*18)+".gif"
document.write("<body background="+s+">")
document.write("</body>")
</script>
红绿蓝三种颜色:
<script>
s=new Array(3)
s[0]="ff0000"
s[1]="00ff00"
s[2]="0000ff"
i=Math.floor(Math.random()*3)
document.write("<body bgcolor="+s+">")
document.write("</body>")
</script>
按钮上:
<script>
s=new Array(3)
s[0]="ff0000"
s[1]="00ff00"
s[2]="0000ff"
i=Math.floor(Math.random()*3)
document.write("<input type='button' value='按钮' style=background-color:"+s+">")
</script>
随机显示图片:
将以下代码加在<head>与</head>之间。
<script LANGUAGE="JavaScript">
bg = new Array(3); //设定图片数量2
bg[1] = 'icon/1.gif' //显示的图片路径
bg[2] = 'icon/2.gif'
bg[3] = 'icon/3.gif'
index = Math.floor(Math.random()*bg.length);
document.write("<BODY BACKGROUND="+bg[index]+">");
</script>
ourhome - 2008-11-4 19:56:00
只能三个颜色而已 如果需要255*255*255种颜色随机 可以查看我主页的 心情记录页面字体颜色
chujian - 2008-11-4 20:20:00
:#1 :#1
sowworld - 2008-11-4 20:32:00
:#1 :#1 :Z1 :Z1