G
Guest
Gast
Hallo an alle,
ich werkel nun schon seit 2 Stunden an diesem blöden Schnee Script!
Irgendwie haut es nicht hin, dass die Flocken sich bewegen.
Ich sehe oben links immer nur 2 kleine stehende Flocken!
Egal welchen Browser ich benutzte... es bleibt immer gleich!
Wo liegt mein Fehler?
<html>
<head>
<script type='text/javascript'>
<!--
var no = 18; // Anzahl der Schneeflocken
var speed = 25; // Geschwindigkeit -> je kleiner die Zahl, desto schneller
var snowflake = "snow.gif";
var dx, xp, yp; // coordinate and position variables
var am, stx, sty; // amplitude and step variables
var i, doc_width, doc_height;
doc_width = 800;
doc_height = 1100;
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 = 0; // set coordinate variables
xp = Math.random()*(doc_width-50); // set position variables
yp = Math.random()*doc_height;
am = Math.random()*20; // set amplitude variables
stx = 0.02 + Math.random()/10; // set step variables
sty = 0.7 + Math.random(); // set step variables
if (i == 0) {
document.write("<div id=\"schneedot"+ i +"\" style=\"position: ");
document.write("absolute; z-index: "+ i +"; visibility: ");
document.write("visible; top: 15px; left: 15px;\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></div>");
} else {
document.write("<div id=\"schneedot"+ i +"\" style=\"position: ");
document.write("absolute; z-index: "+ i +"; visibility: ");
document.write("visible; top: 15px; left: 15px;\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></div>");
}
}
function snowIE() { // IE main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
yp += sty;
if (yp > doc_height-50) {
xp = Math.random()*(doc_width-am-30);
yp = 0;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
}
dx += stx;
document.getElementById("schneedot"+i).style.top = yp + "px";
document.getElementById("schneedot"+i).style.left = (xp + am*Math.sin(dx)) + "px";
}
setTimeout("snowIE()", speed);
}
//-->
</script>
</head>
</html>
ich werkel nun schon seit 2 Stunden an diesem blöden Schnee Script!
Irgendwie haut es nicht hin, dass die Flocken sich bewegen.
Ich sehe oben links immer nur 2 kleine stehende Flocken!
Egal welchen Browser ich benutzte... es bleibt immer gleich!
Wo liegt mein Fehler?
<html>
<head>
<script type='text/javascript'>
<!--
var no = 18; // Anzahl der Schneeflocken
var speed = 25; // Geschwindigkeit -> je kleiner die Zahl, desto schneller
var snowflake = "snow.gif";
var dx, xp, yp; // coordinate and position variables
var am, stx, sty; // amplitude and step variables
var i, doc_width, doc_height;
doc_width = 800;
doc_height = 1100;
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 = 0; // set coordinate variables
xp = Math.random()*(doc_width-50); // set position variables
yp = Math.random()*doc_height;
am = Math.random()*20; // set amplitude variables
stx = 0.02 + Math.random()/10; // set step variables
sty = 0.7 + Math.random(); // set step variables
if (i == 0) {
document.write("<div id=\"schneedot"+ i +"\" style=\"position: ");
document.write("absolute; z-index: "+ i +"; visibility: ");
document.write("visible; top: 15px; left: 15px;\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></div>");
} else {
document.write("<div id=\"schneedot"+ i +"\" style=\"position: ");
document.write("absolute; z-index: "+ i +"; visibility: ");
document.write("visible; top: 15px; left: 15px;\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></div>");
}
}
function snowIE() { // IE main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
yp += sty;
if (yp > doc_height-50) {
xp = Math.random()*(doc_width-am-30);
yp = 0;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
}
dx += stx;
document.getElementById("schneedot"+i).style.top = yp + "px";
document.getElementById("schneedot"+i).style.left = (xp + am*Math.sin(dx)) + "px";
}
setTimeout("snowIE()", speed);
}
//-->
</script>
</head>
</html>