189 8069 5689

javascript雪花,js雪花特效

淘宝里首页飘雪花 怎么弄啊 js代码放在哪里啊 本人小白 希望大神详解.....

div class="J_TWidget" data-widget-config="{'duration':0.1,'activeTriggerCls':'.tshop-psm-shop-ww-hover','interval':0.1,'effect':'scrollx','activeIndex':1,'navCls':'user-crzysj','contentCls':'user-crzysjii','autoplay':true}" data-widget-type="Carousel" style="position:relative;"ul class="user-crzysjii" style="display: none; width: 999999px; left: 0px; position: absolute;"li class="-_-switchable-panel-internal535 ks-switchable-panel-internal998" style="width: 475px; height: 800px; display: block; float: left;" /li/ulul class="user-crzysj"li class="-_-switchable-trigger-internal534 ks-switchable-trigger-internal997 tshop-psm-shop-ww-hover" style="width:475px;height:800px;right:50%;margin-right:505px;"embed allownetworking="all" allowscriptaccess="never" flashvars="scene=taobao_shop" height="1000" name="flashfirebug_1387778983714" src="" type="application/x-shockwave-flash" width="475" wmode="transparent"/li/ul/divdiv class="J_TWidget" data-widget-config="{'duration':0.1,'activeTriggerCls':'.tshop-psm-shop-ww-hover','interval':0.1,'effect':'scrollx','activeIndex':1,'navCls':'user-crzysj','contentCls':'user-crzysjii','autoplay':true}" data-widget-type="Carousel" style="position:relative;z-index:99;"ul class="user-crzysjii" style="display: none; width: 999999px; left: 0px; position: absolute;"li class="-_-switchable-panel-internal635 ks-switchable-panel-internal1108" style="width: 475px; height: 800px; display: block; float: left;" /li/ulul class="user-crzysj"li class="-_-switchable-trigger-internal634 ks-switchable-trigger-internal1107 tshop-psm-shop-ww-hover" style="width:475px;height:800px;left:50%;margin-left:505px;"embed allownetworking="all" allowscriptaccess="never" flashvars="scene=taobao_shop" height="1000" name="flashfirebug_1387778983652" src="" type="application/x-shockwave-flash" width="475" wmode="transparent"/li/ul/div

成都创新互联公司-专业网站定制、快速模板网站建设、高性价比兰溪网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式兰溪网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖兰溪地区。费用合理售后完善,10余年实体公司更值得信赖。

直接在首页添加个自定义模块 编辑 点两个箭头的那个编辑代码模式 然后复制代码放进去 确定就好!

网页飘雪花的代码是什么

在后台添加js特效可实现这样的效果。

js代码为:

script language="JavaScript"

!--

var no = 5; //雪片数目

var speed = 20; //飘动速度。(值越大越慢)

var ns4up = (document.layers) ? 1 : 0; //当前浏览器类型,如果是NS则为1

var ie4up = (document.all) ? 1 : 0; //当前浏览器类型,如果是IE则为1

var s, x, y, sn, cs;

var a, r, cx, cy;

var i, doc_width = 800, doc_height = 600;

x = new Array();

y = new Array();

r = new Array();

cx = new Array();

cy = new Array();

s = 8; //每次下落的高度,越小越平滑,但是也越慢

if (ns4up) { //以NS兼容方式

doc_width = self.innerWidth; //取页面宽度

doc_height = self.innerHeight; //取页面高度

}

else

if (ie4up) { //以IE兼容方式

doc_width = document.body.clientWidth; //取页面宽度

doc_height = document.body.clientHeight; //取页面高度

}

for (i = 0; i no; ++ i) { //根据前面定义的雪片数目写进相应数目的层

initSnow(); //随机初始化层的坐标

if (ns4up) { //如果浏览器是NS

//用layer作为雪片(星号)的容器

document.write("layer name=\"dot"+ i +"\" left=\"1\" ");

document.write("top=\"1\" visibility=\"show\"font color=\"red\"");

document.write("*/font/layer");

}

else

if (ie4up) { //如果浏览器是IE

//用div作为雪片的容器

document.write("div id=\"dot"+ i +"\" style=\"POSITION: ");

document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");

document.write("visible; TOP: 15px; LEFT: 15px;\"font color=\"red\"");

document.write("*/font/div");

}

}

//初始化雪片,生成随机坐标

function initSnow() {

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 makeSnow() {

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 updateSnow() {

r[i] += s;

x[i] = r[i] * sn + cx[i];

y[i] = r[i] * cs + cy[i];

}

//在NS浏览器上处理雪片下落的主程序

function SnowdropNS() {

for (i = 0; i no; ++ i) { //依次处理每片雪花

updateSnow(); //下落

if ((x[i] = 1) || (x[i] = (doc_width - 20)) || (y[i] = (doc_height - 20))) { //如果超出屏幕范围

makeSnow(); //则调整雪片到新位置上

doc_width = self.innerWidth; //更新页面宽度数据

doc_height = self.innerHeight; //更新页面高度数据

}

document.layers["dot"+i].top = y[i]; //改变层的Y坐标,应用新的位置

document.layers["dot"+i].left = x[i]; //改变层的X坐标,应用新的位置

}

setTimeout("SnowdropNS()", speed);

}

//在IE浏览器上处理雪片下落的主程序

function SnowdropIE() {

for (i = 0; i no; ++ i) { //依次处理每片雪花

updateSnow(); //下落

if ((x[i] = 1) || (x[i] = (doc_width - 20)) || (y[i] = (doc_height - 20))) { //如果超出屏幕范围

makeSnow(); //则调整雪片到新位置上

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("SnowdropIE()", speed); //准备下一次下落过程。

}

if (ns4up) { //如果是NS

SnowdropNS(); //调用SnowdropNS使雪片下落

}

else

if (ie4up) { //如果是NS

SnowdropIE(); //调用SnowdropIE使雪片下落

}

--

/script

说明:可以根据自己的需求根据说明进行相应参数的修改

javaScript雪花飘落

script type="text/javascript"

var snowsrc="snow.png"//图片自选

var no = 11; // snow number

var speed = 11; // smaller number moves the snow faster

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 = 1000, doc_height = 1200;

if (ns4up) {

doc_width = self.innerWidth;

doc_height = self.innerHeight;

} else if (ie4up) {

doc_width = 1000;

doc_height = 2000;

}

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\" top=\"15\" visibility=\"show\"img src='"+snowsrc+"' border=\"0\"/layer");

} else {

document.write("layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"img src='"+snowsrc+"' border=\"0\"/layer");

}

} else if (ie4up) {

if (i == 0) {

document.write("div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"img src='"+snowsrc+"' border=\"0\"/a/div");

} else {

document.write("div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"img src='"+snowsrc+"' 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()", 10);

}

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()", 10);

}

if (ns4up) {

snowNS();

} else if (ie4up) {

snowIE();

}

/script

qq空间免费挂件代码

免费挂件

可以去装扮空间--专区--中国心连心那里看,有免费的,

点装扮后保存就可以了图片可以添加图片模块图片模块:复制想要添加进入的图片的地址,可右击图片选属性,那里就有地址。

如果是添加电脑里的图就先把图片上传到相册里--自定义—添加模块—选图片模块--把地址粘贴进图片地址里--在更多设置里面设置无边框--确定后调大小及位置后保存。

javascript 简单的雪花飘落代码 带注释

html

head

title网页特效|Linkweb.cn/Js|---页面漫天飞雪/title

meta http-equiv="Content-Type" content="text/html; charset=gb2312"

/head

body bgcolor="#000000" onLoad="snow()"

script language="JavaScript"

!--

N = 40;

//声明为数组的变量

Y = new Array();

X = new Array();

S = new Array();

A = new Array();

B = new Array();

M = new Array();

/*document.layers是Netscape 4.x专有的属性,是一个代表所有由储如divlayer等定位了的元素的数组。通常也是用div或layer对象的id属性来引用的,但是这里面不包含除此以外的其它元素。

*/

V = (document.layers)?1:0;

iH=(document.layers)?window.innerHeight:window.document.body.clientHeight;//clientHeight 就是浏览器里面那个空白的高

iW=(document.layers)?window.innerWidth:window.document.body.clientWidth; //clentWidth 是浏览器里面那个空白的宽

for (i=0; i N; i++){

/*Math的round(double d)

方法的内容就是

返回最接近参数的 long。通过加上 1/2 将该结果舍入为整数,取结果的基数并将其强制转换为 long 类型。换句话说,结果等于以下表达式的值:

(long)Math.floor(a + 0.5d)

为什么加0.5? 当然是代码就这么写的

1. 如果参数为正数,且小数点后第一位=5,运算结果为参数的整数部分+1。

2. 如果参数为负数,且小数点后第一位5,运算结果为参数的整数部分-1。

3. 如果参数为正数,且小数点后第一位5;或者参数为负数,且小数点后第一位=5,运算结果为参数的整数部分。

Math.random()返回一个伪随机数 n,其中 0 = n 1。返回的数字之所以是一个伪随机数是因为它不是由真正的随机自然现象(如放射性衰变)生成的数字。

*/

//随机获取浏览器空白区的高和宽 赋值给Y和X

Y[i]=Math.round(Math.random()*iH);

X[i]=Math.round(Math.random()*iW);

//设定S A B M的随机取值范围

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){//判断页面是否存在div 和 layer 等元素 第一次访问浏览器肯定是没有的所以v = 0 所以要先生存div 或 layer 等元素

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")}//生成layer 元素 生成背景

}

else{

//这段代码就是生成雪花

document.write('div style="position:absolute;top:0px;left:0px"');//生成div 元素

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()',30); //定时器 每隔30毫秒执行一次

}

//--

/script

script language="Javascript"

!--

function selectAll(theField){

var tempval=eval("document."+theField)

tempval.focus()

tempval.select()

}

//--

/script

/table

/body

求网页飘雪花源代码

把下列代码加到网页的Body/Body标签之间

html

head

title:::飘雪花效果:::网页特效代码:::失落网家园;/title

/head

BODY bgcolor="#000000"

SCRIPT language=JavaScript1.2

var snowsrc="img/snow.gif"

var no = 10;

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 = 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();

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\" top=\"15\" visibility=\"show\"a href=\"\"img src='"+snowsrc+"' border=\"0\"/a/layer");

} else {

document.write("layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"img src='"+snowsrc+"' border=\"0\"/layer");

}

} else if (ie4up) {

if (i == 0) {

document.write("div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"a href=\"\"img src='"+snowsrc+"' border=\"0\"/a/div");

} else {

document.write("div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"img src='"+snowsrc+"' 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()", 10);

}

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()", 10);

}

if (ns4up) {

snowNS();

} else if (ie4up) {

snowIE();

}

/SCRIPT

table border="0" width="100%" cellpadding="0"

tr

td width="100%"font color="#ffffff" size="2"b飘雪花效果/b注意保存这个图片(img border="1" src="img/snow.gif" width="16" height="17")/font/td

/tr

tr

td width="100%"

/table

script language="JavaScript" type="text/javascript" src="js.js"/scripttr/body

/html


本文标题:javascript雪花,js雪花特效
文章起源:http://cdxtjz.cn/article/dssppgj.html

其他资讯