***页面背景***在你的网页中加入下雨的效果
把下列代码加到网页的<body></body>标签之间 从google下载我的照片管理软件要完成此效果把如下代码加入到<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 = 1;
sn = math.sin(a);
cs = math.cos(a);
cx = math.random() * doc_width + 1;
cy = math.random() * doc_height + 1;
x = r * sn + cx;
y = cy;
}
function makerain() {
r = 1;
cx = math.random() * doc_width + 1;
cy = 1;
x = r * sn + cx;
y = r * cs + cy;
}
function updaterain() {
r += s;
x = r * sn + cx;
y = r * cs + cy;
}
function raindropns() {
for (i = 0; i < no; ++ i) {
updaterain();
if ((x <= 1) || (x >= (doc_width - 20)) || (y >= (doc_height - 20))) {
makerain();
doc_width = self.innerwidth;
doc_height = self.innerheight;
}
document.layers["dot"+i].top = y;
document.layers["dot"+i].left = x;
}
settimeout("raindropns()", speed);
}
function raindropie() {
for (i = 0; i < no; ++ i) {
updaterain();
if ((x <= 1) || (x >= (doc_width - 20)) || (y >= (doc_height - 20))) {
makerain();
doc_width = document.body.clientwidth;
doc_height = document.body.clientheight;
}
document.all["dot"+i].style.pixeltop = y;
document.all["dot"+i].style.pixelleft = x;
}
settimeout("raindropie()", speed);
}
if (ns4up) {
raindropns();
}
else
if (ie4up) {
raindropie();
}
-->
</script>
--------------------------------------
http://www.huoyue.com.cn 活跃网,活跃人群的论坛,访问活跃网,将给您带来意想不到的收获,还可以免费为您开论坛,让您免费拥有与朋友、网友交流的论坛。你是年轻人吗?你活跃你就上!
页:
[1]