Вот вам еще один код с ЕГи, где пасусь переодически...
Исходный код
<script LANGUAGE="JavaScript1.2">
//<!-- Begin
var no = 15; // количество рисунков
var speed = 30; // скорость движения;
var clientPC = navigator.userAgent.toLowerCase();
var is_ie_old = (clientPC.indexOf("msie") != -1&&clientPC.indexOf("opera") == -1&&clientPC.indexOf("msie 7.") == -1);
if (is_ie_old)
{
var snowflake = "/conference/images/sneg1.gif"; //адрес рисунка
}
else
{
var snowflake = "/conference/images/sneg1.png"; //адрес рисунка
}
var dx, xp, yp;
var am, stx, sty;
var i;
var doc_width;
var doc_height;
var deadin;
deadin=0;
window.onresize= message;
doc_width = document.body.offsetWidth;
this.documentHeight = (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
doc_height=this.documentHeight;
function message() {
doc_width = document.body.offsetWidth;
this.documentHeight = (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
doc_height=this.documentHeight;
}
function message2() {
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-80);
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
}
}
function message3(i) {
yp[i]=doc_height+50;
deadin=deadin+1;
document.getElementById('plt').innerHTML='<font color=\"#FF0000\">Поймано снежинок :' + deadin+ ' </font> ';
}
for (i = 0; i < no; ++ i) {
document.write("<div id=\"dot"+ i +"\"style='position:absolute;left:-25px;top:-25px;' onclick='message3("+ i +")' ");
document.write("><img src=\"");
document.write(snowflake + "\" border=\"0\"></div>");
}
function snow() {
for (i = 0; i < no; ++ i) {
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width - am[i]-50);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
}
dx[i] += stx[i];
document.getElementById("dot"+i).style.top = yp[i] + "px";
document.getElementById("dot"+i).style.left = (xp[i] + am[i]*Math.sin(dx[i])) + "px";
}
setTimeout("snow()", speed);
}
setTimeout("message()", 1000);
setTimeout("message2()", 1100);
setTimeout("snow()", 1200);
// End -->
</script>
Do. Or do not. There is no Try!
© Master Joda, Dagobah, Star Wars: Episode V.