运行时,按F5便可看效果!
<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[i]+">")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[i]+">")</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> -
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18