>
抽 屉 抽 屉 8290好朋友

【代码】樱花飘落

花露水 2010-07-24
<SCRIPT language=JavaScript>
<!-- Original: Altan (snow@altan.hr) -->
<!-- Web Site: http://www.altan.hr/snow -->
<!-- Smaller flakes, subtle snowfall variables, code beautifcation and makeSnow function by NoSLZZP -->

var no = 6; // snow number
var speed = 12; // smaller number moves the snow faster
var snowflake = "http://www.jscode.cn/Uploadfile/2006819224938886.GIF";

var ns4up = (document.layers) ? 1 : 0; // browser sniffer
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp; // coordinate and position variables
var am, stx, sty; // amplitude and step variables
var i, doc_width = 400, doc_height = 500;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = 500;
doc_height = 500;
}
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; // set coordinate variables
xp[i] = Math.random()*(doc_width-50); // s...<layer name=\"dot"+ i +"\" left=\"15\" ");
document.write("top=\"15\" visibility=\"show\"></layer><layer name=\"dot"+ i +"\" left=\"15\" ");
document.write("top=\"15\" visibility=\"show\"></layer>< no; ++ i) { // iterate for every dot
yp[i] += sty[i];
if (yp[i] >< no; ++ i) { // iterate for every dot
yp[i] += sty[i];
if (yp[i] ></SCRIPT>
<SCRIPT language=JavaScript>
<!-- Original: Altan (snow@altan.hr) -->
<!-- Web Site: http://www.altan.hr/snow -->
<!-- Smaller flakes, subtle snowfall variables, code beautifcation and makeSnow function by NoSLZZP -->

var no = 6; // snow number
var speed = 12; // smaller number moves the snow faster
var snowflake = "http://www.jscode.cn/Uploadfile/2006819224938886.GIF";

var ns4up = (document.layers) ? 1 : 0; // browser sniffer
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp; // coordinate and position variables
var am, stx, sty; // amplitude and step variables
var i, doc_width = 400, doc_height = 500;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = 500;
doc_height = 500;
}
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; // set coordinate variables
xp[i] = Math.random()*(doc_width-50); // set position variables
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20; // set amplitude variables
stx[i] = 0.02 + Math.random()/10; // set step variables
sty[i] = 0.7 + Math.random(); // set step variables
if (ns4up) { // set layers
if (i == 0) {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
document.write("top=\"15\" visibility=\"show\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></layer>");
} else {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
document.write("top=\"15\" visibility=\"show\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></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;\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></div>");
} else {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></div>");
}
}
}
function snowNS() { // Netscape main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
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() { // IE main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
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>

放在自定义HTML、INDEX都可以

其实放哪都OK,另外,如果嫌太长可以用JS保存起来再引用.
预览:http://www.weboac.com/Knowledge/SpeciallyGoodEffect/texiao/tx22/2010-07/20100715091348406141119.htm

打开上面的网址,然后清空代码框里的东西,黏贴本贴上面的代码,运行就可以了。
0
显示全文

查看更多有趣的豆瓣小组

回应 (9条) 只看楼主

  • [已注销]
    这个只是时钟代码吧?怎么说是樱花飘落?
  • 五瓶
    很漂亮~谢谢lz

    ls你看看lz的最后一句啊……

  • [已注销]
    囧。。。原谅我没看清楚。。。
    很漂亮的樱花
  • Apricity
    嗯。看到咯。效果是只在左边有樱花飘落的吧?
  • 花露水
    @ls 全屏的,它会自己飘过去
  • ranniefish
    像粉色的羽毛...

    很美丽呐...XDDD
  • ❤ A。
    像粉色的羽毛... +1

    好看。
  • 呆呢鹿夢遊中
    马克
    ~
    thx
  • Sweki
    啊用不了
添加回应

更多相关帖子

推荐小组

值得一读

    豆瓣
    我们的精神角落
    免费下载 iOS / Android 版客户端