当前位置: 首页 > 图文教程 > 网络编程 > Javascript > javascript设计漫天雪花

Javascript
javascript事件问题
jquery tools 系列 scrollable学习
Javascript中的var_dump函数实现代码
javascript 获取select下拉列表值的代码
JS 网页彩蛋 实现代码
javascript 定义初始化数组函数
Javascript 阻止浏览器默认操作的实现代码
Javascript 检测、添加、移除样式(className)函数代码
Javascript String.replace的妙用
用 Javascript 验证表单(form)中多选框(checkbox)值
用 Javascript 验证表单(form)中的单选(radio)值
Javascript 获取滚动条位置等信息的函数
用Javascript 和 CSS 实现脚注(Footnote)效果
禁止JQuery中的load方法装载IE缓存中文件的方法
jquery 简单导航实现代码
JS 日期验证正则附asp日期格式化函数
javascript 一些用法小结
关于javascript 回调函数中变量作用域的讨论
一个简单的JavaScript 日期计算算法
javascript 基础简介 适合新手学习

Javascript 中的 javascript设计漫天雪花


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-04   浏览: 261 ::
收藏到网摘: n/a

  原代码插入到<body>下面:<script language="JavaScript">
<!--
N = 40;
Y = new Array();
X = new Array();
S = new Array();
A = new Array();
B = new Array();
M = new Array();
V = (document.layers)?1:0; iH=(document.layers)?window.innerHeight:window.document.body.clientHeight;
iW=(document.layers)?window.innerWidth:window.document.body.clientWidth;
for (i=0; i < N; i++){
Y[i]=Math.round(Math.random()*iH);
X[i]=Math.round(Math.random()*iW);
S[i]=Math.round(Math.random()*5+2);
A[i]=0;
B[i]=Math.random()*0.1+0.1;
M[i]=Math.round(Math.random()*1+1);
}
if (V){
for (i = 0; i < N; i++)
{document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,"+M[i]+","+M[i]+"'></LAYER>")}
}
else{
document.write('<div style="position:absolute;top:0px;left:0px">');
document.write('<div style="position:relative">');
for (i = 0; i < N; i++)
{document.write('<div id="si" style="position:absolute;top:0;left:0;width:'+M[i]+';height:'+M[i]+';background:#fffff0;font-size:'+M[i]+'"></div>')}
document.write('</div></div>');
}
function snow(){
var H=(document.layers)?window.innerHeight:window.document.body.clientHeight;
var W=(document.layers)?window.innerWidth:window.document.body.clientWidth;
var T=(document.layers)?window.pageYOffset:document.body.scrollTop;
var L=(document.layers)?window.pageXOffset:document.body.scrollLeft;
for (i=0; i < N; i++){
sy=S[i]*Math.sin(90*Math.PI/180);
sx=S[i]*Math.cos(A[i]);
Y[i]+=sy;
X[i]+=sx;
if (Y[i] > H){
Y[i]=-10;
X[i]=Math.round(Math.random()*W);
M[i]=Math.round(Math.random()*1+1);
S[i]=Math.round(Math.random()*5+2);
}
if (V){document.layers['sn'+i].left=X[i];document.layers['sn'+i].top=Y[i]+T}
else{si[i].style.pixelLeft=X[i];si[i].style.pixelTop=Y[i]+T}
A[i]+=B[i];
}
setTimeout('snow()',10);
}
//-->
</script>
把<body>中的内容改为:
<body bgcolor=#ffffff onLoad="snow()">