注册
|
登录
|
设为首页
|
加入收藏
首页
新闻动态
软件应用
图形图像
硬件IT
电脑安全
编程开发
精文荟萃
游戏娱乐
焦点人物
教学视频
互联网
专题
您当前的位置:飞翔学院-IT中国 →
编程开发
→
JavaScript
→ 文章内容
满天飞舞的梅花
作者:佚名 来源:不详 发布时间:2008-5-23 9:03:28
必须将 JS 代码放在 body 区
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>满天飞舞的梅花</title></head><body><SCRIPT LANGUAGE="JavaScript1.2"><!-- Beginvar no = 12; // number of heartsvar speed = 10; // smaller number moves the hearts fastervar heart = "/upload/42/meihua.gif";var flag;var ns4up = (document.layers) ? 1 : 0; // browser sniffervar ie4up = (document.all) ? 1 : 0;var dx, xp, yp; // coordinate and position variablesvar am, stx, sty; // amplitude and step variablesvar 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;}dx = new Array();xp = new Array();yp = new Array();amx = new Array();amy = new Array();stx = new Array();sty = new Array();flag = new Array();for (i = 0; i < no; ++ i) {dx[i] = 0; // set coordinate variablesxp[i] = Math.random()*(doc_width-30)+10; // set position variablesyp[i] = Math.random()*doc_height;amy[i] = 12+ Math.random()*20; // set amplitude variablesamx[i] = 10+ Math.random()*40;stx[i] = 0.02 + Math.random()/10; // set step variablessty[i] = 0.7 + Math.random(); // set step variablesflag[i] = (Math.random()>0.5)?1:0;if (ns4up) { // set layersif (i == 0) {document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");document.write("top=\"15\" visibility=\"show\"><img src=\"");document.write(heart+ "\" border=\"0\"></layer>");} else {document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");document.write("top=\"15\" visibility=\"show\"><img src=\"");document.write(heart+ "\" border=\"0\"></layer>");}} elseif (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(heart+ "\" 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(heart+ "\" border=\"0\"></div>");}}}function snowNS() { // Netscape main animation functionfor (i = 0; i < no; ++ i) { // iterate for every dotif (yp[i] > doc_height-50) {xp[i] = 10+ Math.random()*(doc_width-amx[i]-30);yp[i] = 0;flag[i]=(Math.random()<0.5)?1:0;stx[i] = 0.02 + Math.random()/10;sty[i] = 0.7 + Math.random();doc_width = self.innerWidth;doc_height = self.innerHeight;}if (flag[i])dx[i] += stx[i];elsedx[i] -= stx[i];if (Math.abs(dx[i]) > Math.PI) {yp[i]+=Math.abs(amy[i]*dx[i]);xp[i]+=amx[i]*dx[i];dx[i]=0;flag[i]=!flag[i];}document.layers["dot"+i].top = yp[i] + amy[i]*(Math.abs(Math.sin(dx[i])+dx[i]));document.layers["dot"+i].left = xp[i] + amx[i]*dx[i];}setTimeout("snowNS()", speed);}function snowIE() { // IE main animation functionfor (i = 0; i < no; ++ i) { // iterate for every dotif (yp[i] > doc_height-50) {xp[i] = 10+ Math.random()*(doc_width-amx[i]-30);yp[i] = 0;stx[i] = 0.02 + Math.random()/10;sty[i] = 0.7 + Math.random();flag[i]=(Math.random()<0.5)?1:0;doc_width = document.body.clientWidth;doc_height = document.body.clientHeight;}if (flag[i])dx[i] += stx[i];elsedx[i] -= stx[i];if (Math.abs(dx[i]) > Math.PI) {yp[i]+=Math.abs(amy[i]*dx[i]);xp[i]+=amx[i]*dx[i];dx[i]=0;flag[i]=!flag[i];}document.all["dot"+i].style.pixelTop = yp[i] + amy[i]*(Math.abs(Math.sin(dx[i])+dx[i]));document.all["dot"+i].style.pixelLeft = xp[i] + amx[i]*dx[i];}setTimeout("snowIE()", speed);}if (ns4up) {snowNS();} else if (ie4up) {snowIE();}// End --></script></body></html>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
打印文档
推荐好友
返回顶部
增大字体
减少字体
上一篇文章:
非常酷的螺旋特效(推荐)
下一篇文章:
如何弹出帮助窗口
分类推荐
·
状态栏左右移动的文字
·
状态栏单字变化的文字
·
彩色变换的文字
·
状态栏滚动文字特效
·
嵌套marquee,产生特别效果
·
通过改变大小写来形成的状态栏特效
·
方块经过的地方文字由大写变为小写
·
如何将状态栏特效用到标题栏
·
如何使超链接被点击后不出现虚线框
·
渐显的超链接文字(很酷)
·
文字快速依次弹出
·
文字从左依次弹出
热点文章
·
满天飞舞的梅花
精采文章
·
电脑城技术资料:超全Windows...
·
[图文]
23项改进 Windows 7对...
·
淘宝网信誉被炒卖 250元可买...
·
[图文]
Windows生日快乐 二十...
·
[图文]
低配置电脑也能使Vist...
精采文章
·
电脑城技术资料:超全Windows...
·
[图文]
23项改进 Windows 7对...
·
淘宝网信誉被炒卖 250元可买...
·
[图文]
Windows生日快乐 二十...
·
[图文]
低配置电脑也能使Vist...
关于本站
|
工作机会
|
合作网站
|
广告服务
|
市场合作
|
联系我们
|
抽奖活动
版权所有: 武汉威俊科技有限公司 Copyright 2005-2007 www.ITCNW.COM All rights reserved