var i=(new Date()).getSeconds() % 10 +1; //系统秒数整除10取余+1,简化的随机数生
<script language="JavaScript" > var i=Math.round(Math.random()*1); var b=Math.round(Math.random()*4); var message="六月哈时光"; var bgpic = new Array("http://www.mtpic.com/preview/4th123.JPG","http://www.mtpic.com/preview/4th064.JPG","http://sunnywoods.myrice.com/index.files/picture/plant-1-n.jpg","http://cactusfan.nease.net/cactus112700/Ariocarpusagavoides3flower.jpg","http://218.4.156.91/txp/2000-4/picture3/ych.jpg"); var my_array = new Array("http://www.chinadv.com/forum/Web/UpFiles/2004/5/9/15133561.swf","http://www.mydeskcity.com/Images/drip.swf");
for(i=1;i<=1;i++) {
myNum=rand(30);
if(myNum<10){
document.write("<img src='http://www.blogcn.com/icon/1/32pic0"+myNum+".gif'>");
document.write("<font class='tt_title'>for(进步=0;进步<梦想;进步++)</font>");
}else
{
document.write("<img src='http://www.blogcn.com/icon/1/32pic"+myNum+".gif'>");
document.write("<font class='tt_title'>for(进步=0;进步<梦想;进步++)</font>");
}
}
请问?
你是怎么搞到这个代码的????
象上面的myNum=rand(30);就是在0到30之间取随机数,根据结果对要输出的路径进行构造就行了。
random 方法
请参阅
Math 对象方法应用于:Math 对象
要求
版本 1
返回介于 0 和 1 之间的伪随机数。Math.random( )
说明
产生的伪随机数介于 0 和 1 之间(含 0,不含 1),也就是,返回值可能为0,但总是小于1。在第一次加载 JScript 时随机数发生器自动产生 。
var i=Math.round(Math.random()*1);
var b=Math.round(Math.random()*4);
var message="六月哈时光";
var bgpic = new Array("http://www.mtpic.com/preview/4th123.JPG","http://www.mtpic.com/preview/4th064.JPG","http://sunnywoods.myrice.com/index.files/picture/plant-1-n.jpg","http://cactusfan.nease.net/cactus112700/Ariocarpusagavoides3flower.jpg","http://218.4.156.91/txp/2000-4/picture3/ych.jpg");
var my_array = new Array("http://www.chinadv.com/forum/Web/UpFiles/2004/5/9/15133561.swf","http://www.mydeskcity.com/Images/drip.swf");
document.write( "<table width=579 height=400 background='"+bgpic[b]+"'>"
+"<tr>"
+"<td valign=top align=left> "
+"<div id=layer1 style='width:500px; height:650px; position:absolute; z-index:1;'>"
+"<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='450' height='550'>"
+"<param name='movie' value='"+my_array[i]+"'>"
+"<param name='quality' value='high'>"
+"<param name='menu' value='false'>"
+"<param name='wmode' value='transparent'>"
+"</object>"
+"</div>"
+"<textarea name='textaread' cols='35' rows='8' id='textaread' style='background-color: #669933;font-size:24px;color: #FFFFFF;filter: Alpha(Opacity=65); '>"+message+"</textarea>"
+"</td>"
+"</tr>"
+"</table>");
</script>为了在一个论坛上玩作的
我写的教程