查看完整版本: 花落片片背景效果

25-1-2010 18:20

花落片片背景效果

<SCRIPT language=JavaScript>
<!--飄落圖案的數量-->
var no = 10;
<!--圖片飄落的速度,數值越小越快-->
var speed = 40;
<!--在此修改飄落圖案連結網址-->
var falling = "http://www.bunbunhk.com/BBS/js/sakura.png";
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 600, doc_height = 800;
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[i] = 0;
xp[i] = Math.random()*(doc_width-50);
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
if (ns4up) {
if (i == 0) {
document.write("<layer name=\"dot"+ i +"\" left=\"20\" top=\"10\" visibility=\"show\"><img src=\"" + falling + "\" border=\"0\"></layer>");
} else {
document.write("<layer name=\"dot"+ i +"\" left=\"20\" top=\"10\" visibility=\"show\"><img src=\"" + falling + "\" border=\"0\"></layer>");
}
} else if (ie4up) {
if (i == 0) {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 10px; LEFT: 20px;\"><img src=\"" + falling + "\" border=\"0\"></div>");
} else {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 10px; LEFT: 20px;\"><img src=\"" + falling + "\" border=\"0\"></div>");
} } }
function snowNS() {
for (i = 0; i < no; ++ i) {
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
dx[i] += stx[i];
document.layers["dot"+i].top = yp[i];
document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowNS()", speed);
}
function snowIE() {
for (i = 0; i < no; ++ i) {
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7+ Math.random();
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx[i] += stx[i];
document.all["dot"+i].style.pixelTop = yp[i];
document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowIE()", speed);
}
if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}
</SCRIPT>




<P><A href="http://www.bunbunhk.com/BBS/js/sakura.png">http://www.bunbunhk.com/BBS/js/sakura.png</A>&nbsp; </P>
<P>&nbsp;</P>
<P>上為圖片網址,可改用樹葉或其他花圖檔</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P><BR>&lt;SCRIPT language=JavaScript&gt; <BR>&lt;!--飄落圖案的數量--&gt;<BR>var no = 10; <BR>&lt;!--圖片飄落的速度,數值越小越快--&gt;<BR>var speed = 40; <BR>&lt;!--在此修改飄落圖案連結網址--&gt;<BR>var falling = "<A href="http://www.bunbunhk.com/BBS/js/sakura.png">http://www.bunbunhk.com/BBS/js/sakura.png</A>"; <BR>var ns4up = (document.layers) ? 1 : 0; <BR>var ie4up = (document.all) ? 1 : 0; <BR>var dx, xp, yp;<BR>var am, stx, sty; <BR>var i, doc_width = 600, doc_height = 800; <BR>if (ns4up) { <BR>doc_width = self.innerWidth; <BR>doc_height = self.innerHeight; <BR>} else if (ie4up) { <BR>doc_width = document.body.clientWidth; <BR>doc_height = document.body.clientHeight; <BR>} <BR>dx = new Array(); <BR>xp = new Array(); <BR>yp = new Array(); <BR>am = new Array(); <BR>stx = new Array(); <BR>sty = new Array(); <BR>for (i = 0; i &lt; no; ++ i) { <BR>dx[i] = 0; <BR>xp[i] = Math.random()*(doc_width-50);<BR>yp[i] = Math.random()*doc_height; <BR>am[i] = Math.random()*20;<BR>stx[i] = 0.02 + Math.random()/10;<BR>sty[i] = 0.7 + Math.random();<BR>if (ns4up) {<BR>if (i == 0) { <BR>document.write("&lt;layer name=\"dot"+ i +"\" left=\"20\" top=\"10\" visibility=\"show\"&gt;&lt;img src=\"" + falling + "\" border=\"0\"&gt;&lt;/layer&gt;"); <BR>} else { <BR>document.write("&lt;layer name=\"dot"+ i +"\" left=\"20\" top=\"10\" visibility=\"show\"&gt;&lt;img src=\"" + falling + "\" border=\"0\"&gt;&lt;/layer&gt;"); <BR>} <BR>} else if (ie4up) { <BR>if (i == 0) { <BR>document.write("&lt;div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 10px; LEFT: 20px;\"&gt;&lt;img src=\"" + falling + "\" border=\"0\"&gt;&lt;/div&gt;"); <BR>} else { <BR>document.write("&lt;div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 10px; LEFT: 20px;\"&gt;&lt;img src=\"" + falling + "\" border=\"0\"&gt;&lt;/div&gt;"); <BR>} } } <BR>function snowNS() {<BR>for (i = 0; i &lt; no; ++ i) {<BR>yp[i] += sty[i]; <BR>if (yp[i] &gt; doc_height-50) { <BR>xp[i] = Math.random()*(doc_width-am[i]-30); <BR>yp[i] = 0; <BR>stx[i] = 0.02 + Math.random()/10; <BR>sty[i] = 0.7 + Math.random(); <BR>doc_width = self.innerWidth; <BR>doc_height = self.innerHeight; <BR>} <BR>dx[i] += stx[i]; <BR>document.layers["dot"+i].top = yp[i]; <BR>document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]); <BR>} <BR>setTimeout("snowNS()", speed); <BR>} <BR>function snowIE() { <BR>for (i = 0; i &lt; no; ++ i) {<BR>yp[i] += sty[i]; <BR>if (yp[i] &gt; doc_height-50) { <BR>xp[i] = Math.random()*(doc_width-am[i]-30); <BR>yp[i] = 0; <BR>stx[i] = 0.02 + Math.random()/10; <BR>sty[i] = 0.7+ Math.random(); <BR>doc_width = document.body.clientWidth; <BR>doc_height = document.body.clientHeight; <BR>} <BR>dx[i] += stx[i]; <BR>document.all["dot"+i].style.pixelTop = yp[i]; <BR>document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]); <BR>} <BR>setTimeout("snowIE()", speed); <BR>} <BR>if (ns4up) { <BR>snowNS(); <BR>} else if (ie4up) { <BR>snowIE(); <BR>} <BR>&lt;/SCRIPT&gt;</P>

25-5-2013 12:04

複製上列語法

<form name="copy">
<textarea cols="40" name="txt" rows="4" style="BACKGROUND-COLOR:#ffffff; COLOR:#000000; FONT-SIZE:9pt">
<SCRIPT language=JavaScript>
<!--飄落圖案的數量-->
var no = 10;
<!--圖片飄落的速度,數值越小越快-->
var speed = 40;
<!--在此修改飄落圖案連結網址-->
var falling = "http://www.bunbunhk.com/BBS/js/sakura.png";
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 600, doc_height = 800;
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[i] = 0;
xp[i] = Math.random()*(doc_width-50);
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
if (ns4up) {
if (i == 0) {
document.write("<layer name=\"dot"+ i +"\" left=\"20\" top=\"10\" visibility=\"show\"><img src=\"" + falling + "\" border=\"0\"></layer>");
} else {
document.write("<layer name=\"dot"+ i +"\" left=\"20\" top=\"10\" visibility=\"show\"><img src=\"" + falling + "\" border=\"0\"></layer>");
}
} else if (ie4up) {
if (i == 0) {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 10px; LEFT: 20px;\"><img src=\"" + falling + "\" border=\"0\"></div>");
} else {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 10px; LEFT: 20px;\"><img src=\"" + falling + "\" border=\"0\"></div>");
} } }
function snowNS() {
for (i = 0; i < no; ++ i) {
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
dx[i] += stx[i];
document.layers["dot"+i].top = yp[i];
document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowNS()", speed);
}
function snowIE() {
for (i = 0; i < no; ++ i) {
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7+ Math.random();
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx[i] += stx[i];
document.all["dot"+i].style.pixelTop = yp[i];
document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowIE()", speed);
}
if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}
</SCRIPT>
</textarea><br>
<input onclick="javascript:this.form.txt.focus();this.form.txt.select();" type="button" value="全選">
</form>

<BR>

<script type="text/javascript"><!--
google_ad_client = "ca-pub-4078143172638881";
/* 336X280 */
google_ad_slot = "3268225205";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
頁: [1]
查看完整版本: 花落片片背景效果