發新話題
打印

[分享] 可愛飄圖(下雪特效)

可愛飄圖(下雪特效)

注意:
留言板〔用了飄雪便不可用滑鼠帶圖〕
〔用滑鼠帶一幅圖可共用飄雪較果〕
第二行〔圖〕等如圖片網址
第三行〔var no = 15;〕15 等如飄多小幅圖

<SCRIPT language=JavaScript1.2>
var dollarsrc="圖片網址"
var no = 15;
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 400, doc_height = 200;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;}
dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
for (i = 0; i < no; ++ i) {
dx = 0; // set coordinate variables
xp = Math.random()*(doc_width-50);
yp = Math.random()*doc_height;
am = Math.random()*20;
stx = 0.04 + Math.random()/15;
sty = 0.9 + Math.random();
if (ns4up) {
if (i == 0) {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src="+dollarsrc+" border=\"0\"></a></layer>");
} else {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src="+dollarsrc+" border=\"0\"></layer>");}} else if (ie4up) {if (i == 0) {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 30px; LEFT: 15px;\"><img src="+dollarsrc+" border=\"0\"></a></div>");
} else {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 30px; LEFT: 15px;\"><img src="+dollarsrc+" border=\"0\"></div>");
}}}function snowNS() {
for (i = 0; i < no; ++ i) {
yp += sty;
if (yp > doc_height+100) {
xp = Math.random()*(doc_width-am-30);
yp = 0;
stx = 0.04 + Math.random()/20;
sty = 0.9 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;}
dx += stx;
document.layers["dot"+i].top = yp;
document.layers["dot"+i].left = xp + am*Math.sin(dx);
}setTimeout("snowNS()", 20);}function snowIE() {
for (i = 0; i < no; ++ i) {
yp += sty;
if (yp > doc_height+100) {
xp = Math.random()*(doc_width-am-30);
yp = 0;
stx = 0.04 + Math.random()/20;
sty = 0.8 + Math.random();
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}dx += stx;document.all["dot"+i].style.pixelTop = yp;
document.all["dot"+i].style.pixelLeft = xp + am*Math.sin(dx);}setTimeout("snowIE()", 20);}if (ns4up) {
snowNS();} else if (ie4up) {snowIE();}</SCRIPT>

[ 本帖最後由 良叡 於 2006-9-27 20:09 編輯 ]

TOP

發新話題