javascript

位置:IT落伍者 >> javascript >> 浏览文章

JavaScript:雪景


发布日期:2022年06月03日
 
JavaScript:雪景

将下列代码加入<body>区语种

<SCRIPT LANGUAGE=JavaScript>

<! Begin

var no = ; // number of hearts

var speed = ; // smaller number moves the hearts faster

var heart = //image/xueGIF;

var flag;

var nsup = (documentlayers) ? : ; // browser sniffer

var ieup = (documentall) ? : ;

var dx xp yp; // coordinate and position variables

var am stx sty; // amplitude and step variables

var i doc_width = doc_height = ;

if (nsup) {

doc_width = selfinnerWidth;

doc_height = selfinnerHeight;

} else if (ieup) {

doc_width = documentbodyclientWidth;

doc_height = documentbodyclientHeight;

}

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 = ; i < no; ++ i) {

dx[i] = ; // set coordinate variables

xp[i] = Mathrandom()*(doc_width)+; // set position variables

yp[i] = Mathrandom()*doc_height;

amy[i] = + Mathrandom()*; // set amplitude variables

amx[i] = + Mathrandom()*;

stx[i] = + Mathrandom()/; // set step variables

sty[i] = + Mathrandom(); // set step variables

flag[i] = (Mathrandom()>)?:;

if (nsup) { // set layers

if (i == ) {

documentwrite(<layer name=\dot+ i +\ left=\\ );

documentwrite(top=\\ visibility=\show\><img src=\);

documentwrite(heart+ \ border=\\></layer>);

} else {

documentwrite(<layer name=\dot+ i +\ left=\\ );

documentwrite(top=\\ visibility=\show\><img src=\);

documentwrite(heart+ \ border=\\></layer>);

}

} else

if (ieup) {

if (i == ) {

documentwrite(<div id=\dot+ i +\ style=\POSITION: );

documentwrite(absolute; ZINDEX: + i +; VISIBILITY: );

documentwrite(visible; TOP: px; LEFT: px;\><img src=\);

documentwrite(heart+ \ border=\\></div>);

} else {

documentwrite(<div id=\dot+ i +\ style=\POSITION: );

documentwrite(absolute; ZINDEX: + i +; VISIBILITY: );

documentwrite(visible; TOP: px; LEFT: px;\><img src=\);

documentwrite(heart+ \ border=\\></div>);

}

}

}

function snowNS() { // Netscape main animation function

for (i = ; i < no; ++ i) { // iterate for every dot

if (yp[i] > doc_height) {

xp[i] = + Mathrandom()*(doc_widthamx[i]);

yp[i] = ;

flag[i]=(Mathrandom()<)?:;

stx[i] = + Mathrandom()/;

sty[i] = + Mathrandom();

doc_width = selfinnerWidth;

doc_height = selfinnerHeight;

}

if (flag[i])

dx[i] += stx[i];

else

dx[i] = stx[i];

if (Mathabs(dx[i]) > MathPI) {

yp[i]+=Mathabs(amy[i]*dx[i]);

xp[i]+=amx[i]*dx[i];

dx[i]=;

flag[i]=!flag[i];

}

documentlayers[dot+i]top = yp[i] + amy[i]*(Mathabs(Mathsin(dx[i])+dx[i]));

documentlayers[dot+i]left = xp[i] + amx[i]*dx[i];

}

setTimeout(snowNS() speed);

}

function snowIE() { // IE main animation function

for (i = ; i < no; ++ i) { // iterate for every dot

if (yp[i] > doc_height) {

xp[i] = + Mathrandom()*(doc_widthamx[i]);

yp[i] = ;

stx[i] = + Mathrandom()/;

sty[i] = + Mathrandom();

flag[i]=(Mathrandom()<)?:;

doc_width = documentbodyclientWidth;

doc_height = documentbodyclientHeight;

}

if (flag[i])

dx[i] += stx[i];

else

dx[i] = stx[i];

if (Mathabs(dx[i]) > MathPI) {

yp[i]+=Mathabs(amy[i]*dx[i]);

xp[i]+=amx[i]*dx[i];

dx[i]=;

flag[i]=!flag[i];

}

documentall[dot+i]stylepixelTop = yp[i] + amy[i]*(Mathabs(Mathsin(dx[i])+dx[i]));

documentall[dot+i]stylepixelLeft = xp[i] + amx[i]*dx[i];

}

setTimeout(snowIE() speed);

}

if (nsup) {

snowNS();

} else if (ieup) {

snowIE();

}

// End >

</script>

               

上一篇:JS判断两种格式的输入日期的正确性

下一篇:JavascriptTip(1)操作剪贴板