紫龙
|
分享:
▼
x0
|
[JScript][教学] [范例]网页特效
在网页增加美美的特效
<SCRIPT language=JavaScript> <!-- var number =12 var speed = 50 var maximg =2 var act = new Array(),positionX = new Array(),positionY = new Array() var moveX = new Array(),moveY = new Array() var j = maximg img = new Array() img[0] = "1.gif" img[1] = "2.gif" img[2] = "3.gif" for (var i = 0; i < number ;++ i) { act = 0 positionX = Math.random()*document.body.clientWidth-50 positionY = Math.random()*document.body.clientHeight moveX = 0.1 + Math.random()/100 moveY = 0.1 + Math.random()*3 if (i == 0) { document.write("<div id=\"fly"+ i +"\" style=\"POSITION] + "\" border=\"0\"></div>")} else { document.write("<div id=\"fly"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible\"><img src=\"" + img[j] + "\" border=\"0\"></div>")} if (j == 0) { j = maximg } else { j -= 1 } } function gofly() { for (var i = 0; i < number ;++ i) { // iterate for every fly positionY -= moveY act += moveX document.all["fly"+i].style.pixelTop = positionY+ Math.cos(act)*positionY/15 document.all["fly"+i].style.pixelLeft = positionX + Math.sin(act)*positionX/50 if (positionY < 0) { moveX = 0.1+ Math.random()/100 moveY = 0.1 + Math.random()*3 positionX = Math.random()*document.body.clientWidth-50 positionY = document.body.clientHeight } } setTimeout("gofly()", speed) } gofly() --> </SCRIPT>
在 var number =12 中修改图片出现的数量 在 var speed = 50 中修改变换的速度 在 var maximg =2 中修改图片的数量(真实数量-1) 自行修改图片的名称或路径
[ 此文章被codeboy在2004-12-11 01:02重新编辑 ]
|