0


歡迎光臨!! 救國團台中學苑 社會教育研習中心 電腦班隊研習營【網頁設計課程】


圖片/背景特效語法




飛舞背景圖片

 

在網頁要呈現的地方中加入


<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] = "http://wssh0812.myweb.hinet.net/05/gif/mou/20061119123406266.gif"
img[1] = "http://wssh0812.myweb.hinet.net/05/gif/mou/20061119123406266.gif"
img[2] = "http://wssh0812.myweb.hinet.net/05/gif/mou/20061119123406266.gif"
for (var i = 0; i < number ;++ i) {
act[i] = 0
positionX[i] = Math.random()*document.body.clientWidth-50
positionY[i] = Math.random()*document.body.clientHeight
moveX[i] = 0.1 + Math.random()/100
moveY[i] = 0.1 + Math.random()*3
if (i == 0)
{
document.write("<div id=\"fly"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible\"><img src=\"" + img[j] + "\" 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[i] -= moveY[i]
act[i] += moveX[i]
document.all["fly"+i].style.pixelTop = positionY[i]+ Math.cos(act[i])*positionY[i]/15
document.all["fly"+i].style.pixelLeft = positionX[i] + Math.sin(act[i])*positionX[i]/50
if (positionY[i] < 0) {
moveX[i] = 0.1+ Math.random()/100
moveY[i] = 0.1 + Math.random()*3
positionX[i] = Math.random()*document.body.clientWidth-50
positionY[i] = document.body.clientHeight
}
}
setTimeout("gofly()", speed)
}
gofly()
-->
</script>

 

----------------------------

在 var number =12 中修改圖片出現的數量
在 var speed = 50 中修改變換的速度
在 var maximg =2 中修改圖片的數量(真實數量-1)
自行修改圖片的名稱或路徑
 


上一頁下一頁 │                                      │ 回首頁 回特效語法  │