[JS] Подскажите скрипт снежинок

volant

Хочу на сайт добавить снежинки в стиле нового года. У когонить он есть? Дайте плз...

gopnik1994

опять сезонное обострение
попробуй придумать что-нть оригинальное
а то эти снежинки на каждом втором сайте появляются и висят потом до марта потому что начинающему веб-мастеру, изучающему jascript, нравится...
ну достало, чесно слово!
З.Ы. Сам через это

vall

добавь оригинальности (глядя в окно) например снегоуборочные машины.

volant

А на сайт выставлять вот так?
<script type="text/javascript" src="./snow.js"></script>
не работает

volant

Вставил вот так и всеравно ничего не видно.
Возможно нехватает вот этого?
return "/icons/snow0"+(cnt%3+1)+".gif"; } else { return "/icons/snow1"+(cnt%3+1)+".gif";
 

<script language="JavaScript" type="text/javascript">
var no = 6; // ? ?
var speed = 60; // ? ?
var cnt = 0;
function getSnowflake {
  cnt++;
  if (Math.random > 0.00 || cnt <= no*2) {
    return "/icons/snow0"+(cnt%3+1)+".gif";
  } else {
    return "/icons/snow1"+(cnt%3+1)+".gif";
    cnt = cnt%3;
  }
}
  var ns4up = (document.layers) ? 1 : 0;
  var ie4up = (document.all) ? 1 : 0;
  var mozilla = (document.getElementById && !ie4up) ? 1 : 0;
  
  var dx, xp, yp;
  var am, stx, sty;
  var i, doc_width = 800, doc_height = 600;
  if (ns4up) {
    doc_width = self.innerWidth;
    doc_height = self.innerHeight;
  } else if (ie4up || mozilla) {
    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;
    xp[i] = Math.random*(doc_width-50);
    yp[i] = Math.random*doc_height;
    am[i] = Math.random*20;
    stx[i] = 0.02 + Math.random/10;
    sty[i] = 0.7 + Math.random;
    if (ns4up) {
     document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
     document.write("top=\"15\" visibility=\"show\"><img src=\"");
     document.write(getSnowflake + "\" border=\"0\" name=\"pic"+ i +"\"></layer>");
    } else if (mozilla) {
     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(getSnowflake + "\" border=\"0\" id=\"pic"+ i +"\"></div>");
    } else if (ie4up) {
     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(getSnowflake + "\" border=\"0\" name=\"pic"+ i +"\"></div>");
    }
  }
function snowMOZ {
  for (i = 0; i < no; i++) {
    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;
     B = document.getElementById("pic"+i).src = getSnowflake;
    }
    dx[i] += stx[i];
    A = document.getElementById("dot" + i);
    A.style.top = yp[i];
    A.style.left = xp[i] + am[i]*Math.sin(dx[i]);
  }
  setTimeout("snowMOZ", speed);
}
function snowNS {
  for (i = 0; i < no; i++) {
    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;
// document.all["pic"+i].src = getSnowflake;
    }
    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 {
  for (i = 0; i < no; i++) {
    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;
     document.all["pic"+i].src = getSnowflake;
    }
    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 (mozilla) {
  snowMOZ;
} else if (ie4up) {
  snowIE;
}
</script>
Оставить комментарий
Имя или ник:
Комментарий: