查看完整版本: 在网页中加入下雨的效果

707609131 2007-11-16 23:09

在网页中加入下雨的效果

作用:
演示:[url]http://94520.91.tc/%2F2/yanshi4.html[/url]
代码:[code]<body>

<script language="JavaScript">
<!--
var no = 50;
var speed = 1;
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var s, x, y, sn, cs;
var a, r, cx, cy;
var i, doc_width = 800, doc_height = 600;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
else
if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
x = new Array();
y = new Array();
r = new Array();
cx = new Array();
cy = new Array();
s = 8;
for (i = 0; i < no; ++ i) {  
initRain();
if (ns4up) {
if (i == 0) {
document.write("<layer name="dot"+ i +"" left="1" ");
document.write("top="1" visibility="show"><font color="#999999">");
document.write(",</font></layer>");
}
else {
document.write("<layer name="dot"+ i +"" left="1" ");
document.write("top="1" visibility="show"><font color="#999999">");
document.write(",</font></layer>");
   }
}
else
if (ie4up) {
if (i == 0) {
document.write("<div id="dot"+ i +"" style="POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;"><font color="#999999">");
document.write(",</font></div>");
}
else {
document.write("<div id="dot"+ i +"" style="POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;"><font color="#999999">");
document.write(",</font></div>");
      }
   }
}
function initRain() {
a = 6;
r[i] = 1;
sn = Math.sin(a);
cs = Math.cos(a);
cx[i] = Math.random() * doc_width + 1;
cy[i] = Math.random() * doc_height + 1;
x[i] = r[i] * sn + cx[i];
y[i] = cy[i];
}
function makeRain() {
r[i] = 1;
cx[i] = Math.random() * doc_width + 1;
cy[i] = 1;
x[i] = r[i] * sn + cx[i];
y[i] = r[i] * cs + cy[i];
}
function updateRain() {
r[i] += s;
x[i] = r[i] * sn + cx[i];
y[i] = r[i] * cs + cy[i];
}
function raindropNS() {
for (i = 0; i < no; ++ i) {
updateRain();
if ((x[i] <= 1) || (x[i] >= (doc_width - 20)) || (y[i] >= (doc_height - 20))) {
makeRain();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
document.layers["dot"+i].top = y[i];
document.layers["dot"+i].left = x[i];
}
setTimeout("raindropNS()", speed);
}
function raindropIE() {
for (i = 0; i < no; ++ i) {
updateRain();
if ((x[i] <= 1) || (x[i] >= (doc_width - 20)) || (y[i] >= (doc_height - 20))) {
makeRain();
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
document.all["dot"+i].style.pixelTop = y[i];
document.all["dot"+i].style.pixelLeft = x[i];
}
setTimeout("raindropIE()", speed);
}
if (ns4up) {
raindropNS();
}
else
if (ie4up) {
raindropIE();
}

-->
</script>[/code]位置:其他头部信息

附加:比较有用。。

707609131 2007-11-16 23:10

看帖子要回。。。。。。。要道德~~1

HH365 2007-11-16 23:18

效果不错的

miceel 2007-11-17 00:06

天啊!!晕忽忽的

*** 作者被禁止或删除 内容自动屏蔽 ***

707609131 2007-11-17 00:25

呵呵~~!是么?但是很漂亮

okazaki 2007-11-17 00:31

確實不錯啊 免除了FLASH的虛框(應該= =)

707609131 2007-11-17 00:32

还以为我见你一面都不容易勒

Mmp゛╪尛赫。 2007-11-24 06:24

加了.
但是没效果!!

狐狸少爷 2007-11-24 10:20

俺回帖了  俺做人厚道吧!

我爱向日葵 2007-11-24 13:25

很好!顶

707609131 2007-11-24 13:30

回复 8# 的帖子

背景的颜色???

zeyuan 2007-11-24 14:43

顶起来了!
只LZ

紫夜IORI苍月 2007-12-5 13:32

不错,要了

等军阵Z 2007-12-9 12:39

来支持下吧....试试效果~

snowfox111 2007-12-9 17:25

继续等人手滑了。

Geao 2007-12-15 19:08

????,没显示啊

晓绪子 2007-12-16 21:45

:L 我的也是不显示
背景颜色我都设置都黑色了
还是看不见

kyan 2007-12-17 18:00

俺的也是没显示!如果有下雪的更好啊:D

heisechibang 2008-2-2 16:13

顶了DDDDDDDDDDD
页: [1]
查看完整版本: 在网页中加入下雨的效果
查看完整版本: 在网页中加入下雨的效果